Php – Datetime value from database is three hours behind

datetimemysqlphptimezone

I am using DATETIME as a column type and using NOW() to insert. When it prints out, it is three hours behind. What can I do so it works three hours ahead to EST time?

I am using php date to format the DATETIME on my page.

Best Solution

If the date stored in your database by using NOW() is incorrect, then you need to change your MySQL server settings to the correct timezone. If it's only incorrect once you print it, you need to modify your php script to use the correct timezone.

Edit:

Refer to W3schools' convenient php date overview for information on how to format the date using date().

Edit 2:

Either you get GoDaddy to change the setting (doubtful), or you add 3 hours when you insert into the table. Refer to the MySQL date add function to modify your date when you set it in the table. Something like date_add(now(), interval 3 hour) should work.

Your exact problem is described here.