我在mysql '2010-12-08 16:12:12‘中有一个日期时间值
我想用PHP获取到那个日期的秒数,
所以基本上相当于mysql的PHP等价物:
TIME_TO_SEC(TIMEDIFF('2010-12-08 16:12:12',now()))发布于 2010-12-09 04:39:00
嗯?这些函数来自mysql ...
对于PHP,您可以使用strtotime替换它
$diff = strtotime('2010-12-08 16:12:12')-time();发布于 2010-12-09 04:39:17
<?php
$date1 = new DateTime("2010-12-08 16:12:12");
$now = new DateTime();
$difference_in_seconds = $date1->format('U') - $now->format('U');->format('U')将其转换为unix时间戳。
发布于 2010-12-09 04:39:37
试一试
$time_diff = time() - strtotime('2010-12-08 16:12:12');https://stackoverflow.com/questions/4392040
复制相似问题