Why does date get time different from machine time?
I want to use date () to get the current time compared to the value of a datetime type in the database. I used the echo date (' y-m-d h:m:s ') to get it was 2012-04-04 07:04:20
But now my machine time is 2012-04-04 19:47:20, do not know why not the same?
How do I compare two times, do I need to convert to seconds to compare?
My view of the time in PHP.ini is set as follows:
; Default timestamp format.
Ibase.timestampformat = "%y-%m-%d%h:%m:%s"
; Default date format.
Ibase.dateformat = "%y-%m-%d"
; Default time format.
Ibase.timeformat = "%h:%m:%s"
------Solution--------------------
The landlord is using the United States server? Time zone is different.
------Solution--------------------
Time zone issues, modifying php.ini Date.timezone = "Asia/shanghai"
------Solution--------------------
In addition to setting the time zone, the difference between 8 hour minutes is not m OH
echo Date (' y-m-d h:m:s ')
echo Date (' y-m-d h:i:s ')
Go through the manual.
------Solution--------------------
Note the difference between H H
And the M-I handbook is the best.
------Solution--------------------
PHP Code
Date_default_timezone_set (' PRC ');
------Solution--------------------
Sorry, I didn't take a careful look at it and answered it. #4的答案才是正确的
As for comparisons, in MySQL, datetime types can be compared by comparing strings.
For example where ' 2012-3-3 13:34:34 ' > ' time '