不确定您需要unix时间戳的方式或原因。
您可以通过使用
<?php the_time(\'c\'); ?>
 这将输出如下内容
2011-01-22T12:01:09+00:00
 它可能不是unix时间戳,但如果需要,至少可以使用php将其转换为unix时间戳。
下面是一个PHP函数,用于转换为UNIX时间戳。摘自谷歌日历simplepie插件。
    function tstamptotime($tstamp) {
            // converts ISODATE to unix date
            // 1984-09-01T14:21:31Z
            sscanf($tstamp,"%u-%u-%uT%u:%u:%uZ",$year,$month,$day,$hour,$min,$sec);
            $newtstamp=mktime($hour,$min,$sec,$month,$day,$year);
            return $newtstamp;
    }
 更新如果您想获得注释的相对时间,有一种比在unix中计算时间戳并进行所有这些转换更简单的方法。
下面是我正在构建的主题框架中使用的两个函数,它们将为您完成这项工作。
首先将其添加到主题函数中。
function theme_time_passed ($t1, $t2)
{
    if($t1 > $t2) :
      $time1 = $t2;
      $time2 = $t1;
    else :
      $time1 = $t1;
      $time2 = $t2;
    endif;
    $diff = array(
      \'years\' => 0,
      \'months\' => 0,
      \'weeks\' => 0,
      \'days\' => 0,
      \'hours\' => 0,
      \'minutes\' => 0,
      \'seconds\' =>0
    );
    $units = array(\'years\',\'months\',\'weeks\',\'days\',\'hours\',\'minutes\',\'seconds\');
    foreach($units as $unit) :
      while(true) :
         $next = strtotime("+1 $unit", $time1);
         if($next < $time2) :
            $time1 = $next;
            $diff[$unit]++;
         else :
            break;
         endif;
      endwhile;
    endforeach;
    return($diff);
}
function theme_time_since($thetime) 
{
    $diff = theme_time_passed($thetime, strtotime(\'now\'));
    $units = 0;
    $time_since = array();
    foreach($diff as $unit => $value) :
       if($value != 0 && $units < 2) :
            if($value === 1) :
                $unit = substr($unit, 0, -1); #removes the plural "s"
            endif;
           $time_since[]= $value . \' \' .$unit;
           ++$units;        
        endif;
    endforeach;
    $time_since = implode(\', \',$time_since);
    $time_since .= \' ago\';
    $date = $time_since;
    return $date;
 }
现在,您可以在worpdress中获取任何日期格式的相对时间。。帖子或评论。
对于注释,可以在注释代码中执行类似操作。
<?php echo theme_time_since(get_comment_time(\'U\')) ?>
 或者对于post date,在循环中使用此选项。
<?php echo theme_time_since(get_the_time(\'U\')) ?>
 据我所知,你想做的就是这样做。它将日期和时间输出为相对于今天的天数、小时数等。
例如:
45秒前或1天1小时前。。等