Ask the predecessor time stamp to convert PHP into date and use MySQL function to convert to date inconsistent problem
The MySQL database has a table infor, under which there is a field in time and the type is int (10), and there is a data bit under the field: 1383346800
Here's the problem:
I use the PHP function echo date ("Y-m-d h:i:s", 1383346800); The operation result is: 2013-11-01 23:00:00
And with the MySQL function select From_unixtime (1383346800); The operation result is: 2013-11-02 07:00:00
Why the same timestamp PHP and MySQL are two results? Which is the right result? Ask the elder to look under, both methods I need, because I want to use these two methods to compare the results, can let two kinds of results consistent, or is not it? Thank goodness people for helping me!
Share to:
------Solution--------------------
Two are right, there's nothing wrong!
It's just a different point of reference.
For 1383346800 there are
Beijing Time 2013-11-02 07:00:00
GMT 2013-11-01 23:00:00
Just one East eight, 8 hours.
------Solution--------------------
Time zone problem, your PHP reference is Greenwich Mean time, and local time difference of 8 hours.
Date_default_timezone_set (' PRC ') sets the value in the time zone or php.ini to change DATE.TIMEZONE=PRC.