I'm working on a blog migration from a custom built blog to Wordpress. One of the fields that Wordpress is looking for in the database is a date/time stamp set to GMT, which is 4 hours ahead of our time. So I basically need to take our date/time stamp (in YYYY-MM-DD HH:MM:SS format), and add four hours to it. I was looking at the MySQL command "ADDTIME", but I think that only works on selects, not on inserts.
I had worked up a script that exploded the date in to parts, and added 4 hours to the time, but the ensuing logic that would be required to check for when 4 hours pushes in to the next day/month/year seemed a little excessive.
date($format, strtotime("$date + 4 hours"));
There's nothing that prevents ADDTIME()
from being used in an INSERT
OR UPDATE
, but DATE_ADD()
is probably what will work best:
INSERT INTO table_name
SET my_datetime = DATE_ADD('2009-11-01 19:30:00', INTERVAL 4 HOURS),
...other insert columns here... ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With