gmdate() - want 1 hr before time


Posted on 16th Feb 2014 07:03 pm by admin

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

No comments posted yet

Your Answer:

Login to answer
283 Like 54 Dislike
Previous forums Next forums
Other forums

Change log of Cost centre change in Plant maintenance order
Hi,
How to view Change log of Cost centre in Plant maintenance order. Not visible thru 'Docume

Greek characters in php
Hi,

I'm making a script and I m using for first time greek characters.
I started to write

matching numbers inside ( )
I know I can match numbers by just [0-9]+, so I thought matching numbers inside ( ) would be somethi

check if string contain only a-z/A-Z
Is where any way to check if string contains only a-z/A-Z, without writing an array with all possibl

Open/Close Links in Php
Hello, Hoping someone can inform me how I can get PHP to automatically open a set of links in a new

Comparing Values
Hi
I'm reading data from a database and this seems to work OK.

Each system has an associat

Output Buffering question
Hi all,

I've been trying to wrap my head around output buffering. So far I've found tons of

function not returning the correct value
I have a program that needs to return a value from a function. I have an output statement inside the

How to make a input/output field with multiple lines
Hello.
I put a input/output field on the screen but I could not change height of it. I need to

help with insert
Hi there,

I am trying to insert some data into a database, but for some reason, it is not ins

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash