What's the best way to manage dates across PHP, MySQL, etc?

前端 未结 4 660
渐次进展
渐次进展 2021-01-03 03:52

My server is in Dallas. I\'m in New York City.. and both PHP and MySQL have configuration variables for setting the timezone.

How do I get them all to work together

4条回答
  •  没有蜡笔的小新
    2021-01-03 04:39

    I prefer using dates and times in the native form with respect to the environment, that is, Unix timestamps in PHP and DATE/TIME/DATETIME/TIMESTAMP fields in MySQL. I translate both values into another using FROM_UNIXTIME() and UNIX_TIMESTAMP(). I prefer this instead of Unix timestamps, because native dates/times are much easier to read.

提交回复
热议问题