PHP日期或时间戳函数,用于检查在同一天、同一周或一周以上经过的时间
对于PHP,提供年份日期的函数PHP日期或时间戳函数,用于检查在同一天、同一周或一周以上经过的时间,php,date,time,Php,Date,Time,对于PHP,提供年份日期的函数 $date = date('n/j/Y', $time); echo $date; 或者表示为时间戳 $time = strtotime($date); echo $time; 基本上,当我的帖子超过一周的时候,我想把它列为月/日/年。 并被列为星期一、星期二……一周中的某一天,在这一周内发布帖子。 当发帖时间在同一天内时,则表示多少小时前或多少分钟前 我是否需要使用时间戳进行减法以查看经过的时间?我该如何把它带回来,比如说,在同一天
$date = date('n/j/Y', $time);
echo $date;
或者表示为时间戳
$time = strtotime($date);
echo $time;
基本上,当我的帖子超过一周的时候,我想把它列为月/日/年。
并被列为星期一、星期二……一周中的某一天,在这一周内发布帖子。
当发帖时间在同一天内时,则表示多少小时前或多少分钟前
我是否需要使用时间戳进行减法以查看经过的时间?我该如何把它带回来,比如说,在同一天或同一周内,时间流逝了多少
thx$currentTime=time();
如果($currentTime
$currentTime = time();
if ($currentTime < strtotime('1 year ago', $currentTime) {
echo "at least a year old";
} else if ($currentTime < strtotime('1 month ago', $currentTime) {
echo "at least a month old (but not a year)";
} else if ($currentTime < strtotime('1 week ago', $currentTime) {
echo "at least a week old (but not a month)";
} else if ($currentTime < strtotime('1 day ago', $currentTime) {
echo "at least a day old (but not a week)";
}