如何在PHP中删除当前日期()5分钟

时间:2022-12-01 16:03:47

i would like to show me the date minus 5 minutes from the current time; my code is like this:

我想给我看一下从当前时间减去5分钟的日期;我的代码是这样的:

(date('Y-m-d H:i-5:s'))

but it's not correct because this is the dump of it :

但这并不正确,因为这是它的垃圾场:

2012-08-08 13:27-5:49

2012-08-08 13:27-5:49

any ideas how can i do it ? thanks !

有什么办法吗?谢谢!

2 个解决方案

#1


24  

PHP Function:

PHP函数:

strtotime()

strtotime()

Example:

例子:

echo date('Y-m-d H:i:s', strtotime('-5 minutes'));

#2


0  

Try this It's solve your problem

试试看,这能解决你的问题

$format = "h:i A";
date_default_timezone_set('Asia/Kolkata');
echo date($format, strtotime("-5 minute"));

#1


24  

PHP Function:

PHP函数:

strtotime()

strtotime()

Example:

例子:

echo date('Y-m-d H:i:s', strtotime('-5 minutes'));

#2


0  

Try this It's solve your problem

试试看,这能解决你的问题

$format = "h:i A";
date_default_timezone_set('Asia/Kolkata');
echo date($format, strtotime("-5 minute"));