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

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 如何检查此时间戳是今天,明天还是后天?脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道如何检查时间戳是今天,明天还是后天.

我有例如:

$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";
}

脚本宝典总结

以上是脚本宝典为你收集整理的php – 如何检查此时间戳是今天,明天还是后天?全部内容,希望文章能够帮你解决php – 如何检查此时间戳是今天,明天还是后天?所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。