How do I change MySQL timezone?
程序员文章站
2023-09-09 21:09:20
however, there are ways for you to get results...
however, there are ways for you to get results that are in your preferred timezone. first determine how many hours your desired timezone is 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 will give you an est date result. for a result in pst, you would do:
select date_sub(now(), interval 1 hour);
if you are working with time in seconds instead of dates, then factor in the offset in seconds. because there are 3600 seconds in an hour, and est is 2 hours later than mst, the following converts timestamps from mst to 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, you may also need to do one of the following (but not both):
1. find every place in your code where a date or time is displayed to the browser and have 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 are input into your system and have a user defined function add or subtract the appropriate number of hours before storing it.
上一篇: 微信:开展自媒体清理整治专项行动
推荐阅读
-
how dude do i look官网地址是什么
-
how old do i look(how-old.net)怎么玩?HowOldRobot怎么测年龄
-
How do I change MySQL timezone?
-
How do I change MySQL timezone?_PHP教程
-
how dude do i look官网地址是什么
-
how old do i look(how-old.net)怎么玩?HowOldRobot怎么测年龄
-
How do I change MySQL timezone?_php技巧
-
How to fetch data from mysql table using mysql_fetch_assoc i_MySQL
-
How do I change MySQL timezone?_PHP教程
-
How do I change MySQL timezone?