Esempio n. 1
0
<?php

/**
 * @package oxford
 */
?>

<time class="entry-date" datetime="<?php 
esc_attr(the_time('c'));
?>
">
	<?php 
echo esc_html(get_the_date(oxford_get_date_format()));
?>
</time>
Esempio n. 2
0
 /**
  * Shows a relative time stamp if the publish date is less than 24 hours old.
  *
  * @since 1.0.
  *
  * @param  int|string $from Unix timestamp from which the difference begins.
  * @param  int|string $to   Optional. Unix timestamp to end the time difference. Default becomes time() if not set.
  * @return string           Human readable time difference.
  */
 function oxford_human_time_diff($from, $to = '')
 {
     if (empty($to)) {
         $to = time();
     }
     $diff = (int) abs($to - $from);
     if ($diff < HOUR_IN_SECONDS) {
         $mins = round($diff / MINUTE_IN_SECONDS);
         if ($mins <= 1) {
             $mins = 1;
         }
         $since = sprintf(_n('%s minute ago', '%s minutes ago', $mins, 'oxford'), $mins);
     } elseif ($diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS) {
         $hours = round($diff / HOUR_IN_SECONDS);
         if ($hours <= 1) {
             $hours = 1;
         }
         $since = sprintf(_n('%s hour ago', '%s hours ago', $hours, 'oxford'), $hours);
     } else {
         $since = get_the_date(oxford_get_date_format());
     }
     return $since;
 }