Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想显示距离当前时间减去 5 分钟的日期;我的代码是这样的:
(date('Y-m-d H:i-5:s'))
但这是不正确的,因为var_dump会产生:
var_dump
2012-08-08 13:27-5:49
关于如何做到这一点的任何想法?
PHP函数:
strtotime()
例子:
echo date('Y-m-d H:i:s', strtotime('-5 minutes'));
试试这个解决你的问题
$format = "h:i A"; date_default_timezone_set('Asia/Kolkata'); echo date($format, strtotime("-5 minute"));