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

=> and <=
So I was digging through some code when I came across the <= operator. This is the first tim

Force download script not handling files with spaces properly
I have a regular old php force download script, uses this code:

Code: header("Cache-Cont

Form validation with functions
Hi there

I am trying to make a very simple form validation function. I currently have the fol

Logic question
im wondering what's the best method to do the above list:

it is for alliance @ MMORPG game

Output Full URL of Current Page
Let's say I am currently viewing a dynamic page:

http://www.mydomain.com/directory/index.php

Option box to change variable
Hello, i need help by making a script!

I need to write a file with option box, so a dropdown

Sort Alternative/bi-monthly
Hi all,

Am going mad trying to get something to work.

I'm creating a CMS for a magazi

Multiple arrays inside data
Hi,

Simple question. I have a column called "array" in my database, and inserted in

disable all input buttons
Hello Friends,

suppose i do have a file ( file.php ) has a submit button

Code: [Sele

Table trouble
i have been reading the forum for a few weeks and decided to join. i like the format and the advice

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