如何检查这个时间戳记是今天,明天还是明天? [英] How to make a check if this timestamp is today,tomorrow or the day after tomorrow?

查看:171
本文介绍了如何检查这个时间戳记是今天,明天还是明天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何检查时间戳记是今天,明天还是明天的日期。

I would like to know how to check if the timestamp is today, tomorrow or the day after tomorrow.

$timestamp = "1313000474";

如何检查这个时间戳记是今天,明天还是明天?

How to make a check if this timestamp is today,tomorrow or the day after tomorrow?

例如

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

这篇关于如何检查这个时间戳记是今天,明天还是明天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆