WP_REST_Posts_Controller::prepare_date_response
Checks the post_date_gmt or modified_gmt and prepare any post or modified date for single post output.
Метод класса: WP_REST_Posts_Controller{}
Хуков нет.
Возвращает
Строку|null. ISO8601/RFC3339 formatted datetime.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->prepare_date_response( $date_gmt, $date );
- $date_gmt(строка) (обязательный)
- GMT publication time.
- $date(строка|null)
- Local publication time.
По умолчанию:null
Список изменений
| С версии 4.7.0 | Введена. |
Код WP_REST_Posts_Controller::prepare_date_response() WP REST Posts Controller::prepare date response WP 7.0.1
protected function prepare_date_response( $date_gmt, $date = null ) {
// Use the date if passed.
if ( isset( $date ) ) {
return mysql_to_rfc3339( $date );
}
// Return null if $date_gmt is empty/zeros.
if ( '0000-00-00 00:00:00' === $date_gmt ) {
return null;
}
// Return the formatted datetime.
return mysql_to_rfc3339( $date_gmt );
}