如何从 PHP 中的当前日期()中删除 5 分钟
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11870001/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:19:29 来源:igfitidea点击:
How can i remove 5 minutes from current date() in PHP
提问by Abude
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 var_dumpproduces:
但这不正确,因为var_dump产生:
2012-08-08 13:27-5:49
2012-08-08 13:27-5:49
Any ideas on how can I do this?
关于如何做到这一点的任何想法?
回答by Jason McCreary
PHP Function:
PHP函数:
Example:
例子:
echo date('Y-m-d H:i:s', strtotime('-5 minutes'));
回答by vivek
Try this It's solve your problem
试试这个它解决了你的问题
$format = "h:i A";
date_default_timezone_set('Asia/Kolkata');
echo date($format, strtotime("-5 minute"));

