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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.