加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 如何检查此时间戳是今天,明天还是后天?

发布时间:2020-12-13 13:48:06 所属栏目:PHP教程 来源:网络整理
导读:我想知道如何检查时间戳是今天,明天还是后天. 我有例如: $timestamp = "1313000474"; 如何查看此时间戳是今天,明天还是后天? 例如 if today then echo $output = "today";if tomorrow then echo $output = "tomorrow";if the day after tomorrow then echo
我想知道如何检查时间戳是今天,明天还是后天.

我有例如:

$timestamp = "1313000474";

如何查看此时间戳是今天,明天还是后天?

例如

if today then echo $output = "today";
if tomorrow then echo $output = "tomorrow";
if the day after tomorrow then echo $output = "dayaftertomorrow";

这该怎么做?

编辑:更正了unix时间戳

先感谢您.

$timestamp = "1313000474";

$date = date('Y-m-d',$timestamp);
$today = date('Y-m-d');
$tomorrow = date('Y-m-d',strtotime('tomorrow')); 
$day_after_tomorrow = date('Y-m-d',strtotime('tomorrow + 1 day'));

if ($date == $today) {
  echo "today";
} else if ($date == $tomorrow) {
  echo "tomorrow";
} else if ($date == $day_after_tomorrow) {
  echo "dayaftertomorrow";
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读