troubleshooting Question

MySQL + PHP Timestamp advice

Avatar of marcparillo
marcparillo asked on
10 Comments1 Solution582 ViewsLast Modified:

What's the best method for recording times in a MySQL database?  For years, I've used unix timestamps (i.e. 1323092395) but when I need to take DST into account, it becomes an issue.

For example, Client A wants an e-mail sent to her at 5am every day.  The time is recorded as a unix timestamp in my database.  When DST starts, the server time is automatically adjusted back an hour, and suddenly, Client A starts receiving e-mails at 4am because the unix timestamp is a relative number, not a fixed point in time such as a UTC timestamp.

I've read Ray Paseur's great article from EE about Handling Date and Time in PHP and MySQL, but those solutions are all PHP based.  I would like to do the time adjustments on the MySQL end, so I don't have to perform a time function on every record in the DB.

Should I use UTC, RFC 2822?  If I use those formats, would I be able to perform a MySQL query that takes into account the time change?

Thank you,

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros