考虑:
$created_dt = created_dt->created_dt // string(19) "2013-06-06 15:50:08"我正试图确定从此时起,当前的日期/时间是否大于24小时:
$current_time = date('Y-m-d H:i:s', now());
if($current_time > $created_dt + 24 hours){
//do some things
}如何才能做到这一点?您能够使用日期字符串的<,=,>操作符吗?
我试过:
$created_dt = mktime(date('H')+1); //Seems to add 6 hours to current time
$created_dt = date('Y-m-d H:i:s', now('H'+1)); // Gives me the time and date for now发布于 2014-02-26 22:46:17
要有明天的日期(24小时后),只需增加1天。
$current_time = date('Y-m-d H:i:s', strtotime('+ 1 Day'));实际上,可以将日期字符串与逻辑运算符(如> < = )进行比较。
发布于 2014-02-26 22:45:13
试着做这样的事情:
$current_time = time(); // now (seconds since UNIX epoch)
$test_time = strtotime("2013-06-06 15:50:08"); // same format
if($test_time > $current_time + (24 * 60 * 60)) // 24*60*60 = 24 hours in seconds
echo 'Greater than 24 hours after now';
else
echo 'Less than or equal to 24 hours from now';https://stackoverflow.com/questions/22055099
复制相似问题