Welcome Guest, Not a member yet? Register   Sign In
DATETIME + 6 hours
#1

[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')
but how do you add 6 hrs? You can't just do date('Y-m-d H:iConfused')+6 (or similar). How can you solve this?
#2

[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.
#3

[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
#4

[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. Tongue




Theme © iAndrew 2016 - Forum software by © MyBB