本文整理汇总了PHP中tribe_event_format_date函数的典型用法代码示例。如果您正苦于以下问题:PHP tribe_event_format_date函数的具体用法?PHP tribe_event_format_date怎么用?PHP tribe_event_format_date使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tribe_event_format_date函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tribe_get_end_date
/**
* End Date
*
* Returns the event end date
*
* @param int $event (optional)
* @param bool $displayTime If true shows date and time, if false only shows date
* @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
* @return string Date
*/
function tribe_get_end_date($event = null, $displayTime = true, $dateFormat = '')
{
if (is_null($event)) {
global $post;
$event = $post;
}
if (is_numeric($event)) {
$event = get_post($event);
}
if (tribe_event_is_all_day($event)) {
$displayTime = false;
}
if (empty($event->EventEndDate) && is_object($event)) {
$event->EventEndDate = tribe_get_event_meta($event->ID, '_EventEndDate', true);
}
if (isset($event->EventEndDate)) {
if (tribe_event_is_all_day($event) && empty($event->_end_date_fixed) && TribeDateUtils::timeOnly($event->EventEndDate) != '23:59:59' && TribeDateUtils::timeOnly(tribe_event_end_of_day()) != '23:59') {
// set the event end date to be one day earlier, if it's an all day event and the cutoff is past midnight
// @todo remove this once we can have all day events without a start / end time
$event->EventEndDate = date_create($event->EventEndDate);
$event->EventEndDate->modify('-1 day');
$event->EventEndDate = $event->EventEndDate->format(TribeDateUtils::DBDATEFORMAT);
$event->_end_date_fixed = true;
}
$date = strtotime($event->EventEndDate);
} else {
return;
}
return tribe_event_format_date($date, $displayTime, $dateFormat);
}
示例2: tribe_events_the_mini_calendar_title
/**
* Output a link for the mini calendar month previous nav, includes data attributes needed to update the month with ajax
*
* @return void
**/
function tribe_events_the_mini_calendar_title()
{
$args = tribe_events_get_mini_calendar_args();
$date = strtotime($args['eventDate']);
$date_format = tribe_get_option('monthAndYearFormat', 'M Y');
$title = tribe_event_format_date($date, false, $date_format);
echo apply_filters('tribe_events_the_mini_calendar_title', $title);
}
示例3: tribe_get_end_date
/**
* End Date
*
* Returns the event end date
*
* @param int $postId (optional) this only works for non recurring events
* @param bool $displayTime If true shows date and time, if false only shows date
* @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
* @return string Date
* @todo support $postId for recurring events.
* @since 2.0
*/
function tribe_get_end_date($postId = null, $displayTime = 'true', $dateFormat = '')
{
$postId = TribeEvents::postIdHelper($postId);
if (!$postId || function_exists('tribe_is_recurring_event') && tribe_is_recurring_event($postId)) {
global $post;
} else {
$post = get_post($postId);
}
if (tribe_get_all_day($postId)) {
$displayTime = false;
}
if (empty($post->EventEndDate)) {
$post->EventEndDate = tribe_get_event_meta($postId, '_EventEndDate', true);
}
if (isset($post->EventEndDate)) {
$date = strtotime($post->EventEndDate);
} else {
return;
// '—';
}
return tribe_event_format_date($date, $displayTime, $dateFormat);
}
示例4: tribe_get_end_date
/**
* End Date
*
* Returns the event end date
*
* @param int $event (optional) this only works for non recurring events
* @param bool $displayTime If true shows date and time, if false only shows date
* @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
* @return string Date
* @todo support $postId for recurring events.
* @since 2.0
*/
function tribe_get_end_date($event = null, $displayTime = true, $dateFormat = '')
{
if (is_null($event)) {
global $post;
$event = $post;
}
if (is_numeric($event)) {
$event = get_post($event);
}
if (tribe_event_is_all_day($event)) {
$displayTime = false;
}
if (empty($event->EventEndDate) && is_object($event)) {
$event->EventEndDate = tribe_get_event_meta($event->ID, '_EventEndDate', true);
}
if (isset($event->EventEndDate)) {
$date = strtotime($event->EventEndDate);
} else {
return;
// '—';
}
return tribe_event_format_date($date, $displayTime, $dateFormat);
}
示例5: tribe_mini_display_day
function tribe_mini_display_day($day, $monthView, $month = NULL, $date = NULL)
{
$tribe_ecp = TribeEvents::instance();
$monthName = $tribe_ecp->monthsShort[date('M', $date)];
$dayofweeek = tribe_event_format_date(false, 'D');
$return = "<div class='daynum tribe-events-event' id='daynum_{$day}'>";
$return .= count($monthView[$day]) ? "<a class='tribe-events-mini-has-event'><span class='tribe-month-name'>{$monthName} {$dayofweeek}</span>{$day}</a>" : $day;
/**/
$return .= "<div id='tooltip_day_{$day}' class='tribe-events-tooltip' style='display:none;'>";
for ($i = 0; $i < count($monthView[$day]); $i++) {
$post = $monthView[$day][$i];
setup_postdata($post);
$return .= '<h5 class="tribe-events-event-title-mini"><a href="' . tribe_get_event_link($post) . '">' . $post->post_title . '</a></h5>';
}
//$return .= '<span class="tribe-events-arrow"></span>';
$return .= '</div>';
/**/
$return .= "</div>";
return $return;
}
示例6: tribe_events_the_month_day_classes
<td class="<?php
tribe_events_the_month_day_classes();
?>
"
<?php
if (isset($daydata['daynum'])) {
?>
data-day="<?php
echo $daydata['date'];
?>
"
<?php
//Add Day Name Option for Responsive Header
if ($daydata['total_events'] > 0) {
$day_name = tribe_event_format_date($daydata['date'], false);
?>
data-date-name="<?php
echo $day_name;
?>
"
<?php
}
?>
<?php
}
?>
>
<?php
tribe_get_template_part('month/single', 'day');
示例7: getLink
/**
* Returns various internal events-related URLs
*
* @param string $type type of link. See switch statement for types.
* @param string $secondary for $type = month, pass a YYYY-MM string for a specific month's URL
* for $type = week, pass a Week # string for a specific week's URL
* @param int|bool|null $term
*
* @return string The link.
*/
public function getLink($type = 'home', $secondary = false, $term = null)
{
// if permalinks are off or user doesn't want them: ugly.
if ('' == get_option('permalink_structure')) {
return esc_url_raw($this->uglyLink($type, $secondary));
}
// account for semi-pretty permalinks
if (false !== strpos(get_option('permalink_structure'), 'index.php')) {
$eventUrl = trailingslashit(home_url() . '/index.php/' . sanitize_title($this->getOption('eventsSlug', 'events')));
} else {
$eventUrl = trailingslashit(home_url() . '/' . sanitize_title($this->getOption('eventsSlug', 'events')));
}
// if we're on an Event Cat, show the cat link, except for home and days.
if ($type !== 'home' && is_tax(self::TAXONOMY) && $term !== false && !is_numeric($term)) {
$term_link = get_term_link(get_query_var('term'), self::TAXONOMY);
if (!is_wp_error($term_link)) {
$eventUrl = trailingslashit($term_link);
}
} else {
if ($term) {
$term_link = get_term_link((int) $term, self::TAXONOMY);
if (!is_wp_error($term_link)) {
$eventUrl = trailingslashit($term_link);
}
}
}
switch ($type) {
case 'home':
$eventUrl = trailingslashit(esc_url_raw($eventUrl));
break;
case 'month':
if ($secondary) {
$eventUrl = trailingslashit(esc_url_raw($eventUrl . $secondary));
} else {
$eventUrl = trailingslashit(esc_url_raw($eventUrl . $this->monthSlug));
}
break;
case 'list':
$eventUrl = trailingslashit(esc_url_raw($eventUrl . $this->listSlug));
break;
case 'upcoming':
$eventUrl = trailingslashit(esc_url_raw($eventUrl . $this->listSlug));
break;
case 'past':
$eventUrl = esc_url_raw(add_query_arg('tribe_event_display', 'past', trailingslashit($eventUrl . $this->listSlug)));
break;
case 'dropdown':
$eventUrl = esc_url_raw($eventUrl);
break;
case 'single':
global $post;
$p = $secondary ? $secondary : $post;
$link = trailingslashit(get_permalink($p));
$eventUrl = trailingslashit(esc_url_raw($link));
break;
case 'day':
if (empty($secondary)) {
$secondary = $this->todaySlug;
} else {
$secondary = tribe_event_format_date($secondary, false, Tribe__Events__Date_Utils::DBDATEFORMAT);
}
$eventUrl = trailingslashit(esc_url_raw($eventUrl . $secondary));
break;
default:
$eventUrl = esc_url_raw($eventUrl);
break;
}
return apply_filters('tribe_events_getLink', $eventUrl, $type, $secondary, $term);
}
示例8: tribe_get_events_title
/**
* Event Title
*
* Return an event's title with pseudo-breadcrumb if on a category
*
* @param bool $depth include linked title
*
* @return string title
* @todo move logic to template classes
*/
function tribe_get_events_title($depth = true)
{
$events_label_plural = tribe_get_event_label_plural();
global $wp_query;
$tribe_ecp = Tribe__Events__Main::instance();
$title = sprintf(__('Upcoming %s', 'tribe-events-calendar'), $events_label_plural);
// If there's a date selected in the tribe bar, show the date range of the currently showing events
if (isset($_REQUEST['tribe-bar-date']) && $wp_query->have_posts()) {
if ($wp_query->get('paged') > 1) {
// if we're on page 1, show the selected tribe-bar-date as the first date in the range
$first_event_date = tribe_get_start_date($wp_query->posts[0], false);
} else {
//otherwise show the start date of the first event in the results
$first_event_date = tribe_event_format_date($_REQUEST['tribe-bar-date'], false);
}
$last_event_date = tribe_get_end_date($wp_query->posts[count($wp_query->posts) - 1], false);
$title = sprintf(__('%1$s for %2$s - %3$s', 'tribe-events-calendar'), $events_label_plural, $first_event_date, $last_event_date);
} elseif (tribe_is_past()) {
$title = sprintf(__('Past %s', 'tribe-events-calendar'), $events_label_plural);
}
if (tribe_is_month()) {
$title = sprintf(__('%1$s for %2$s', 'tribe-events-calendar'), $events_label_plural, date_i18n(tribe_get_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date())));
}
// day view title
if (tribe_is_day()) {
$title = sprintf(__('%1$s for %2$s', 'tribe-events-calendar'), $events_label_plural, date_i18n(tribe_get_date_format(true), strtotime($wp_query->get('start_date'))));
}
if (is_tax($tribe_ecp->get_event_taxonomy()) && $depth) {
$cat = get_queried_object();
$title = '<a href="' . esc_url(tribe_get_events_link()) . '">' . $title . '</a>';
$title .= ' › ' . $cat->name;
}
return apply_filters('tribe_get_events_title', $title, $depth);
}
示例9: tribe_get_start_date
<h4 class="event-day"><?php
echo tribe_get_start_date(null, false);
?>
– <?php
echo tribe_get_end_date(null, false);
?>
</h4>
<?php
}
?>
<?php
if (tribe_is_day() && $first) {
$first = false;
?>
<h4 class="event-day"><?php
echo tribe_event_format_date(strtotime(get_query_var('eventDate')), false);
?>
</h4>
<?php
}
?>
<?php
the_title('<h2 class="entry-title" itemprop="name"><a href="' . tribe_get_event_link() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a></h2>');
?>
<div class="entry-content tribe-events-event-entry" itemprop="description">
<?php
if (has_excerpt()) {
?>
<?php
the_excerpt();
?>
示例10: custom_columns
/**
* Add the custom columns.
*
* @param string $column_id The custom column id.
* @param int $post_id The post id for the data.
* @return void
*/
public static function custom_columns($column_id, $post_id)
{
if (self::$events_list && sizeof(self::$events_list) > 0) {
if ($column_id == 'events-cats') {
$event_cats = get_the_term_list($post_id, TribeEvents::TAXONOMY, '', ', ', '');
echo $event_cats ? strip_tags($event_cats) : '—';
}
if ($column_id == 'start-date') {
if (!empty(self::$events_list[0]->EventStartDate)) {
echo tribe_event_format_date(strtotime(self::$events_list[0]->EventStartDate), false);
}
if (!self::$end_col_active || !self::$start_col_first) {
self::advance_date();
}
}
if ($column_id == 'end-date') {
if (!empty(self::$events_list[0]->EventEndDate)) {
echo tribe_event_format_date(strtotime(self::$events_list[0]->EventEndDate), false);
}
if (self::$start_col_first) {
self::advance_date();
}
}
if ($column_id == 'recurring') {
echo sizeof(get_post_meta($post_id, '_EventStartDate')) > 1 ? __("Yes", 'tribe-events-calendar') : __("No", 'tribe-events-calendar');
}
} else {
self::ajax_custom_columns($column_id, $post_id);
}
}
示例11: tribe_get_end_date
/**
* End Date
*
* Returns the event end date
*
* @category Events
* @param int $event (optional)
* @param bool $displayTime If true shows date and time, if false only shows date
* @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
* @param string $timezone Timezone in which to present the date/time (or default behaviour if not set)
*
* @return string|null Date
*/
function tribe_get_end_date($event = null, $displayTime = true, $dateFormat = '', $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_event_is_all_day($event)) {
$displayTime = false;
}
$end_date = Tribe__Events__Timezones::event_end_timestamp($event->ID, $timezone);
return tribe_event_format_date($end_date, $displayTime, $dateFormat);
}
示例12: strtotime
</td>
<?php
}
?>
<td>
<?php
$start_date = strtotime($post->EventStartDate);
echo tribe_event_format_date($start_date, false, TribeCommunityEvents::instance()->eventListDateFormat);
?>
</td>
<td>
<?php
$end_date = strtotime($post->EventEndDate);
echo tribe_event_format_date($end_date, false, TribeCommunityEvents::instance()->eventListDateFormat);
?>
</td>
</tr>
<?php
}
// end list loop
$post = $old_post;
?>
</tbody><!-- #the-list -->
<?php
do_action('tribe_ce_after_event_list_table');
示例13: tribe_events_get_current_month_day
<?php
// Get data for this day within the loop.
$daydata = tribe_events_get_current_month_day();
?>
<td class="<?php
tribe_events_the_month_day_classes();
?>
"
data-day="<?php
echo esc_attr(isset($daydata['daynum']) ? $daydata['date'] : '');
?>
"
data-tribejson='<?php
echo tribe_events_template_data(null, array('date_name' => tribe_event_format_date($daydata['date'], false)));
?>
'
>
<?php
tribe_get_template_part('month/single', 'day');
?>
</td>
<?php
}
?>
</tr>
</tbody>
</table><!-- .tribe-events-calendar -->
<?php
do_action('tribe_events_after_the_grid');
示例14: pre_get_posts
//.........这里部分代码省略.........
// make sure start and end date are set
if ($query->get('start_date') == '') {
$event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : date_i18n(Tribe__Events__Date_Utils::DBDATETIMEFORMAT);
$query->set('start_date', tribe_event_beginning_of_day($event_date));
}
if ($query->get('end_date' == '')) {
$query->set('end_date', tribe_event_end_of_day($query->get('start_date')));
}
$query->set('hide_upcoming', true);
break;
case 'day':
$event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : Date('Y-m-d', current_time('timestamp'));
$query->set('eventDate', $event_date);
$beginning_of_day = strtotime(tribe_event_beginning_of_day($event_date)) + 1;
$query->set('start_date', date_i18n(Tribe__Events__Date_Utils::DBDATETIMEFORMAT, $beginning_of_day));
$query->set('end_date', tribe_event_end_of_day($event_date));
$query->set('posts_per_page', -1);
// show ALL day posts
$query->set('hide_upcoming', true);
$query->set('order', self::set_order('ASC', $query));
break;
case 'single-event':
if ($query->get('eventDate') != '') {
$query->set('start_date', $query->get('eventDate'));
$query->set('eventDate', $query->get('eventDate'));
}
break;
case 'all':
case 'list':
default:
// default display query
$event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : date_i18n(Tribe__Events__Date_Utils::DBDATETIMEFORMAT);
if (!$query->tribe_is_past) {
$query->set('start_date', '' != $query->get('eventDate') ? tribe_event_beginning_of_day($event_date) : tribe_event_format_date(current_time('timestamp'), true, 'Y-m-d H:i:s'));
$query->set('end_date', '');
$query->set('order', self::set_order('ASC', $query));
} else {
// on past view, set the passed date as the end date
$query->set('start_date', '');
$query->set('end_date', tribe_event_end_of_day($event_date));
$query->set('order', self::set_order('DESC', $query));
}
$query->set('orderby', self::set_orderby(null, $query));
$query->set('hide_upcoming', true);
break;
}
} else {
$query->set('hide_upcoming', true);
$query->set('start_date', date_i18n(Tribe__Events__Date_Utils::DBDATETIMEFORMAT));
$query->set('orderby', self::set_orderby(null, $query));
$query->set('order', self::set_order(null, $query));
}
// eventCat becomes a standard taxonomy query - will need to deprecate and update views eventually
if (!in_array($query->get(Tribe__Events__Main::TAXONOMY), array('', '-1'))) {
$tax_query[] = array('taxonomy' => Tribe__Events__Main::TAXONOMY, 'field' => is_numeric($query->get(Tribe__Events__Main::TAXONOMY)) ? 'id' : 'slug', 'terms' => $query->get(Tribe__Events__Main::TAXONOMY), 'include_children' => apply_filters('tribe_events_query_include_children', true));
}
// Only add the postmeta hack if it's not the main admin events list
// Because this method filters out drafts without EventStartDate.
// For this screen we're doing the JOIN manually in Tribe__Events__Admin_List
if (!Tribe__Events__Admin__Helpers::instance()->is_screen('edit-tribe_events')) {
$event_start_key = Tribe__Events__Timezones::is_mode('site') ? '_EventStartDateUTC' : '_EventStartDate';
$meta_query[] = array('key' => $event_start_key, 'type' => 'DATETIME');
}
}
// filter by Venue ID
if ($query->tribe_is_event_query && $query->get('venue') != '') {
示例15: getLink
/**
* Returns various internal events-related URLs
*
* @param string $type type of link. See switch statement for types.
* @param string $secondary for $type = month, pass a YYYY-MM string for a specific month's URL
* for $type = week, pass a Week # string for a specific week's URL
* @param int|bool|null $term
*
* @return string The link.
*/
public function getLink($type = 'home', $secondary = false, $term = null)
{
// if permalinks are off or user doesn't want them: ugly.
if ('' === get_option('permalink_structure')) {
return esc_url_raw($this->uglyLink($type, $secondary));
}
// account for semi-pretty permalinks
if (false !== strpos(get_option('permalink_structure'), 'index.php')) {
$event_url = home_url('/index.php/');
} else {
$event_url = home_url('/');
}
// URL Arguments on home_url() pre-check
$url_query = @parse_url($event_url, PHP_URL_QUERY);
$url_args = wp_parse_args($url_query, array());
// Remove the "args"
if (!empty($url_query)) {
$event_url = str_replace('?' . $url_query, '', $event_url);
}
// Append Events structure
$event_url .= trailingslashit(sanitize_title($this->getOption('eventsSlug', 'events')));
// if we're on an Event Cat, show the cat link, except for home and days.
if ($type !== 'home' && is_tax(self::TAXONOMY) && $term !== false && !is_numeric($term)) {
$term_link = get_term_link(get_query_var('term'), self::TAXONOMY);
if (!is_wp_error($term_link)) {
$event_url = trailingslashit($term_link);
}
} else {
if ($term) {
$term_link = get_term_link((int) $term, self::TAXONOMY);
if (!is_wp_error($term_link)) {
$event_url = trailingslashit($term_link);
}
}
}
switch ($type) {
case 'home':
$event_url = trailingslashit(esc_url_raw($event_url));
break;
case 'month':
if ($secondary) {
$event_url = trailingslashit(esc_url_raw($event_url . $secondary));
} else {
$event_url = trailingslashit(esc_url_raw($event_url . $this->monthSlug));
}
break;
case 'list':
$event_url = trailingslashit(esc_url_raw($event_url . $this->listSlug));
break;
case 'upcoming':
$event_url = trailingslashit(esc_url_raw($event_url . $this->listSlug));
break;
case 'past':
$event_url = esc_url_raw(add_query_arg('tribe_event_display', 'past', trailingslashit($event_url . $this->listSlug)));
break;
case 'dropdown':
$event_url = esc_url_raw($event_url);
break;
case 'single':
global $post;
$p = $secondary ? $secondary : $post;
$link = trailingslashit(get_permalink($p));
$event_url = trailingslashit(esc_url_raw($link));
break;
case 'day':
if (empty($secondary)) {
$secondary = $this->todaySlug;
} else {
$secondary = tribe_event_format_date($secondary, false, Tribe__Events__Date_Utils::DBDATEFORMAT);
}
$event_url = trailingslashit(esc_url_raw($event_url . $secondary));
break;
default:
$event_url = esc_url_raw($event_url);
break;
}
// Filter get link
$event_url = apply_filters('tribe_events_get_link', $event_url, $type, $secondary, $term, $url_args);
// @todo deprecate on 4.2
$event_url = apply_filters('tribe_events_getLink', $event_url, $type, $secondary, $term, $url_args);
// Add the Arguments back
$event_url = add_query_arg($url_args, $event_url);
return $event_url;
}