3 回答

TA贡献1875条经验 获得超3个赞
这只是从时间创建一个 DateTime 对象(默认为今天的日期),如果它小于当前日期和时间,它会增加 1 天...
$date = DateTime::createFromFormat("H:i:s", $get_time2);
if ( $date < new DateTime() ) {
$date->modify("+1 day");
}
这使
2019-11-27 23:00:00
并为$get_time1...
2019-11-28 06:00:00

TA贡献2003条经验 获得超2个赞
如果你使用DateTime那将允许你做日期算术。
$now = new DateTime();
$tomorrow = $now->modify("+1 day");
您还可以使用此答案strtotime中的说明获取 unix 时间戳。
$tomorrow = strtotime('+1 day');

TA贡献1860条经验 获得超8个赞
也许这会做?
$offset = timezone_offset_get( timezone_open( "Europe/London" ), new \DateTime() );
echo 'in London' . gmdate('d-m-Y H:i:s', date( "U" )+$offset);
echo 'current location: ' . date('d-m-Y H:i:s', date( "U" ));
- 3 回答
- 0 关注
- 191 浏览
添加回答
举报