我需要设置时间戳,例如。分别提前4小时和提前2小时
在我的数据库中,我将它们的列作为时间戳。
我知道我可以做类似的事情,但不确定它是否正确。
// For 4 hours ahead of time
$dt2 = date("Y-m-d 04:i:s");
//For 2 days ahead
$dt2 = date("Y-m-02 H:i:s");
最佳答案
//For 4 hours ahead of time
$dt2 = date("Y-m-d H:i:s", strtotime('+4 hours'));
//For 2 days ahead of time
$dt2 = date("Y-m-d H:i:s", strtotime('+2 days'));
关于php - 设置Php和Mysql时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28110361/