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.