|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Adding Time
Hi
I Have this problem, I wish to add 7 hours to a time and date, the date and time are held in the following PHP Code:
This displays the date and time just how i need it, but I need to be able to add seven hours to the openusers value, how can i do this? Many Thanks John |
|
#2
|
|||
|
|||
|
Try MySQL
A great way to do this sort of thing is via a MySQL call (assuming you have access to MySQL)
The following will add 7 hours to the current time and return the new date and time: PHP Code:
You would need to replace NOW() with the date and time you wanted to manipulate of course. Take a look at http://www.mysql.com/doc/en/Date_an..._functions.html for the full story. Hope it helps. |
|
#3
|
|||
|
|||
|
This is also simple to do in your application logic using:
PHP Code:
__________________
~ Joe Penn We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set? Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you. |
|
#4
|
|||
|
|||
|
Hi
Thanks for those replies, but unfortunately it looks like I failed to explain myself properly, The situation is that my site is hosted in a different time zone to where I live, and this is 7 hours different, so because my site has a simple cut-off time, after which site members cannot access a game I run I need this time to be the same as my time. I do not want to mess with the any other parts of the code as it all works ok, but I need to change the value $openusers to be 7 hours ahead of the time and date in the vaules $todaysgamedate $gametime24hour. Hope this explains it a little better Many Thanks John |
|
#5
|
|||
|
|||
|
So what format are the date and time stored in, in the two variables $todaysgamedate and $gametime24hour?
|
|
#6
|
|||
|
|||
|
Hi
$todaysgamedate is stored like this 2003-08-14 $gametime24hour is stored like this 18:25:00 Thanks John |
|
#7
|
|||
|
|||
|
PHP Code:
|
|
#8
|
|||
|
|||
|
or, just to complete the set
![]() PHP Code:
This will also cope with the date change if midnight is passed by the 7 hour increment. Last edited by baines : August 13th, 2003 at 02:13 PM. |
|
#9
|
|||
|
|||
|
Thanks for all the help guys
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Adding Time |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|