php and mysql date time difference

前端 未结 4 721
轮回少年
轮回少年 2021-01-24 15:20

I did this in php to store the lastlogin in a mysql datetime column

date(\'Y-m-d h:i:s\') //which then gave > \'2014-01-04 08:00:56\'

and th

4条回答
  •  执念已碎
    2021-01-24 15:44

    In order to avoid such problems, check the following things.

    1. Make sure that system time and system timezone of both the DB Server and the Application Server are same.
    2. Make sure that you have set the configuration of PHP and MySQL to take proper time-zones.
    3. Always use a single function to set update, insert rows that have a dateTime field in them. Personally, I suggest that you write a common function somewhere in your code, and whenever you need to get the current time, use that function, instead of using the MySQL's NOW()

提交回复
热议问题