DATETIME + 6 hours |
[eluser]codex[/eluser]
I store dates as DATETIME (still don't know how to use timestamps :red: ) and I'm hosting a Dutch site on a US server. Servertime is -6 hours. For insert I use Code: date('Y-m-d H:i:s')
[eluser]ejangi[/eluser]
date() has a second parameter which can be a unix time stamp and you can modify that like so: Code: date('Y-m-d H:i:s', time() + (60 * 60 * 6)); time() is in seconds, so first I've multiplied it by 60 to get minutes and then again by 60 again to get hours and then of course by 6 to make it time() + 6 hours.
[eluser]codex[/eluser]
[quote author="ucantblamem" date="1198038440"]date() has a second parameter which can be a unix time stamp and you can modify that like so: Code: date('Y-m-d H:i:s', time() + (60 * 60 * 6)); time() is in seconds, so first I've multiplied it by 60 to get minutes and then again by 60 again to get hours and then of course by 6 to make it time() + 6 hours.[/quote] Hey thanks!! Didn't know about the second parameter :red: . Thank you for making me look stupid ;-P
[eluser]ejangi[/eluser]
Hehehe... Certainly not my intention, but don't sweat it man - there's so many functions and options for functions in the PHP manual that these things are easily overlooked/forgotten. I do it ALL the time. |
Welcome Guest, Not a member yet? Register Sign In |