TimeZone How does I change MySQL timezone?

Source: Internet
Author: User
However, there is ways for your get results that is in your preferred timezone. First determine how many hours your desired timezone are off from MST. For example, EST is +2 hours. PST is-1 Hour.
Knowing the time offset, you can replace all your SQL statements of
SELECT now ();
With
SELECT Date_add (now (), INTERVAL 2 HOUR);
Which'll give you a EST date result. For a result in PST, you would do:
SELECT Date_sub (now (), INTERVAL 1 HOUR);
If you is working with time in seconds instead of dates, then factor in the offset in seconds. Because there was 3600 seconds in an hour, and EST was 2 hours later than MST, the following converts timestamps from MST t o EST:
SELECT Unix_timestamp () + (3600 * 2);
SELECT From_unixtime (Unix_timestamp () + (3600 * 2));
See the MySQL Manual ' s Date and time Functions for more information.
Depending on your application, your may also need to does one of the following (but not both):
1. Find every place in your code where a date or time was displayed to the browser and has a user defined function change It to add or subtract the appropriate number of hours before displaying it.
2. Find every place in your code where dates or times is input into your system and has a user defined function add or s Ubtract the appropriate number of hours before storing it.

The above describes the timezone how does I change MySQL timezone, including the timezone aspect of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.