Yoast\WP\SEO\Helpers
Date_Helper::format_timestamp
Formats the given timestamp to the needed format.
Метод класса: Date_Helper{}
Хуков нет.
Возвращает
Строку. The formatted date.
Использование
$Date_Helper = new Date_Helper(); $Date_Helper->format_timestamp( $timestamp, $format );
- $timestamp(int) (обязательный)
- The timestamp to use for the formatting.
- $format(строка)
- The format that the passed date should be in.
По умолчанию:\DATE_W3C
Код Date_Helper::format_timestamp() Date Helper::format timestamp Yoast 27.9
public function format_timestamp( $timestamp, $format = \DATE_W3C ) {
if ( ! \is_string( $timestamp ) && ! \is_int( $timestamp ) ) {
return $timestamp;
}
$immutable_date = \date_create_immutable_from_format( 'U', $timestamp, new DateTimeZone( 'UTC' ) );
if ( ! $immutable_date ) {
return $timestamp;
}
return $immutable_date->format( $format );
}