Ejemplo n.º 1
0
 /**
  * Formatted Date
  *
  * Returns formatted date
  *
  * @category Events
  * @param string $date        String representing the datetime, assumed to be UTC (relevant if timezone conversion is used)
  * @param bool   $display_time If true shows date and time, if false only shows date
  * @param string $date_format  Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
  *
  * @return string
  */
 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);
 }