1

Consider the following,

$date = new DateTime(null, new DateTimeZone('Asia/Kolkata'));
$sysdate = date_format($date, 'H:i:s');
echo $sysdate;

Result:  17:31:48

Let me know how to minus 5 minutes from sysdate.

cornelb
  • 6,046
  • 3
  • 19
  • 30
Bala
  • 85
  • 2
  • 12

5 Answers5

6

See this

PHP Function:

strtotime()

Example:

echo date('Y-m-d H:i:s', strtotime('-5 minutes'));
Community
  • 1
  • 1
GajendraSinghParihar
  • 9,051
  • 11
  • 36
  • 64
4

In objective style, you can use method sub and DateInterval object:

$date = new DateTime(null, new DateTimeZone('Asia/Kolkata'));

echo  $date->format('H:i:s').PHP_EOL;
$date->sub(new DateInterval('PT5M'));
echo  $date->format('H:i:s').PHP_EOL;

result:

17:44:04
17:39:04
ziollek
  • 1,973
  • 1
  • 12
  • 10
2

Try this! hope this may help...

$date = new DateTime(null, new DateTimeZone('Asia/Kolkata'));

$sysdate = date_format(strtotime($date), 'H:i:s');

echo date('H:i:s',time($sysdate) - 05*60);

Smit kalwal
  • 422
  • 2
  • 13
1

Not tested, but this might help..$date->sub(new DateInterval('PT0H5M'));

Link::

http://www.php.net/manual/en/datetime.sub.php
Rohit Awasthi
  • 686
  • 3
  • 12
1

$date = strtotime("-5 minutes")

amir beygi
  • 1,234
  • 8
  • 13