我试图比较如下时间:
如果此帖子是在过去6个月的展会期间发布的human_time_diff() else节目the_time(\'j. M .Y\')
我的想法是:
function time_ago() {
  global $post;
  $now = time();
  $post_created = strtotime($post->post_date);
  $sixMonthsAgo = 180*24*60*60;
  $human_time = \'hace \'. human_time_diff( get_the_time(\'U\'), current_time(\'timestamp\') );
  $mobile = wp_is_mobile();
  if (( $now - $post_created ) > $sixMonthsAgo && $mobile) {
   the_time(\'j. M .Y\');
 } elseif(( $now - $post_created ) > $sixMonthsAgo && !$mobile) {
   the_time(\'j. F .Y\');
 } else {
   echo $human_time;
 }
}
 我假装用这个函数来比较帖子发布的日期,因为
time() 以秒为单位我将秒与秒进行比较
$sixMonthsAgo但这只显示了human_time_diff();
没有其他想法。。。
你觉得怎么样?我的逻辑哪里错了?
谢谢