Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i remove 5 minutes from current date() in PHP

Tags:

date

php

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

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

but it's not correct because var_dump produces:

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

Any ideas on how can I do this?

like image 996
Abude Avatar asked Aug 08 '12 17:08

Abude


2 Answers

PHP Function:

strtotime()

Example:

echo date('Y-m-d H:i:s', strtotime('-5 minutes'));
like image 162
Jason McCreary Avatar answered Oct 13 '22 18:10

Jason McCreary


Try this It's solve your problem

$format = "h:i A";
date_default_timezone_set('Asia/Kolkata');
echo date($format, strtotime("-5 minute"));
like image 22
vivek Avatar answered Oct 13 '22 17:10

vivek