tribe_format_date( string $date, bool $display_time = true, string $date_format = '' )
Formatted Date
Returns formatted date
Parameters #
- $date
-
(string) (Required) String representing the datetime, assumed to be UTC (relevant if timezone conversion is used)
- $display_time
-
(bool) (Optional) If true shows date and time, if false only shows date
Default value: true
- $date_format
-
(string) (Optional) Allows date and time formating using standard php syntax (<a href="http://php.net/manual/en/function.date.php">http://php.net/manual/en/function.date.php</a>)
Default value: ''
Return #
(string)
Source #
File: src/functions/template-tags/date.php
function tribe_format_date( $date, $display_time = true, $date_format = '' ) { if ( ! Tribe__Date_Utils::is_timestamp( $date ) ) { $date = strtotime( $date ); } if ( $date_format ) { $format = $date_format; } else { $date_year = date( 'Y', $date ); $cur_year = date( 'Y', current_time( 'timestamp' ) ); // only show the year in the date if it's not in the current year $with_year = $date_year == $cur_year ? false : true; if ( $display_time ) { $format = tribe_get_datetime_format( $with_year ); } else { $format = tribe_get_date_format( $with_year ); } } $date = date_i18n( $format, $date ); /** * Deprecated tribe_event_formatted_date in 4.0 in favor of tribe_formatted_date. Remove in 5.0 */ $date = apply_filters( 'tribe_event_formatted_date', $date, $display_time, $date_format ); return apply_filters( 'tribe_formatted_date', $date, $display_time, $date_format ); }