Jump to content

check if its one hour before time


a.mlw.walker

Recommended Posts

So I am trying to check if the current time is one hour before a variable time:

$date_game=$dt->format('Y n j'.$pieces[2]);
echo $date_game;
echo date('Y n j H');

if (date('Y n j H') < $date_game)  {
echo "The time is before the stored time";
}

 

This displays

2012 1 21 17:30

2012 1 21 16

i.e $pieces[2] = 17:30. and $dt formatted Y n j = 2012 1 21.

The current Y n j H is 2012 1 21 16.

I want to know if it is more than one hour until the date/time stored in $date_game.

 

At the moment it just tells me that it is before that time.

Can I do something like

$data_game - 1->format('H');

or something?

Thanks guys

Link to comment
Share on other sites

so its a plus not a minus!

Sorry If I wasnt clear but basically if $dt->format('Y n j') is the same day as today, i.e date('Y n j) and the hour now is the same as my variable $pieces[2], which in this case stated it was half five, (17:30) then I want to run a condition to check whether it is before half four or not on the day that $dt->format('Y n j') states it is.

 

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.