14

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?

Marcello B.
  • 4,177
  • 11
  • 45
  • 65
Abude
  • 2,112
  • 7
  • 35
  • 58

2 Answers2

47

PHP Function:

strtotime()

Example:

echo date('Y-m-d H:i:s', strtotime('-5 minutes'));
salathe
  • 51,324
  • 12
  • 104
  • 132
Jason McCreary
  • 71,546
  • 23
  • 135
  • 174
2

Try this It's solve your problem

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