tribe_get_start_date( int $event = null, bool $display_time = true, string $date_format = '', string $timezone = null )
Start Date
Contents
Returns the event start date and time
Parameters
- $event
-
(int) (Optional) (optional)
Default value: null
- $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: ''
- $timezone
-
(string) (Optional) Deprecated. Timezone in which to present the date/time (or default behaviour if not set)
Default value: null
Return
(string|null) Date
Source
File: src/functions/template-tags/date.php
function tribe_get_start_date( $event = null, $display_time = true, $date_format = '', $timezone = null ) {
if ( is_null( $event ) ) {
global $post;
$event = $post;
}
if ( is_numeric( $event ) ) {
$event = get_post( $event );
}
if ( ! is_object( $event ) ) {
return '';
}
if ( Tribe__Date_Utils::is_all_day( get_post_meta( $event->ID, '_EventAllDay', true ) ) ) {
$display_time = false;
}
// @todo move timezones to Common
if ( class_exists( 'Tribe__Events__Timezones' ) ) {
$start_date = Tribe__Events__Timezones::event_start_timestamp( $event->ID, $timezone );
} else {
return null;
}
/**
* Filters the returned event start date and time
*
* @param string $start_date
* @param WP_Post $event
*/
return apply_filters( 'tribe_get_start_date', tribe_format_date( $start_date, $display_time, $date_format ), $event );
}
Changelog
| Version | Description |
|---|---|
| 5.2.0 | Updated filter params. |
| 4.7.6 | Introduced. |