Jump to content

gmdate() - want 1 hr before time


rupam_jaiswal

Recommended Posts

Hi,

I am using php gmdate().

Now I am entering all dates in my dbase using gmdate("Y-m-d H:i:s")

I want 1 hr before datetime.

So am using like

gmdate("Y-m-d H:i:s", mktime(gmdate("H")-$hrs, gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d"), gmdate("Y")));

where $hr = 1

When I echo current date i,e

 

$date = gmdate('Y-m-d H:i:s');

echo "<br/>current date is $date";

 

its

2009-12-27 03:54:08

 

and when echo my code of getting 1 hr before

$date1 = gmdate("Y-m-d H:i:s", mktime(gmdate("H")-1, gmdate("i"), gmdate("s"), gmdate("m"), gmdate("d"),  gmdate("Y")));

 

its

2009-12-26 02:54:08

 

difference between these 2 days is 1 day and not 1 hr.

I want 1 hr before datetime to be

2009-12-27 02:54:08

 

Can please anybody help.

Thanks in advance

Regards

Link to comment
https://forums.phpfreaks.com/topic/186368-gmdate-want-1-hr-before-time/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.