Please ask the previous time stamp with PHP conversion to date and the MySQL function to convert to date inconsistent problems

Source: Internet
Author: User
Tags echo date
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.
  • 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.