Why does date get time different from machine time? Solution Ideas

Source: Internet
Author: User
Tags echo date ibase
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 '
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.