3 回答

TA貢獻(xiàn)1875條經(jīng)驗 獲得超3個贊
這只是從時間創(chuàng)建一個 DateTime 對象(默認(rèn)為今天的日期),如果它小于當(dāng)前日期和時間,它會增加 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貢獻(xiàn)2003條經(jīng)驗 獲得超2個贊
如果你使用DateTime那將允許你做日期算術(shù)。
$now = new DateTime();
$tomorrow = $now->modify("+1 day");
您還可以使用此答案strtotime中的說明獲取 unix 時間戳。
$tomorrow = strtotime('+1 day');

TA貢獻(xiàn)1860條經(jīng)驗 獲得超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 關(guān)注
- 187 瀏覽
添加回答
舉報