MySQL: setting time_zone in my.cnf options file

后端 未结 6 2123
遥遥无期
遥遥无期 2020-12-17 15:03

In MySQL you can set a session variable called time_zone to change the timezone. This is useful e.g. when looking at timestamps from another country. Here i

6条回答
  •  盖世英雄少女心
    2020-12-17 15:27

    I'm not certain what has changed in Xampp, but this solution only works if you place this line in the proper place. Trust me I tried many times and had to do a pretty thorough search to find this solution.

    default-time-zone = "+00:00"
    

    Example:

    read_rnd_buffer_size = 512K
    myisam_sort_buffer_size = 8M
    default-time-zone = "+00:00" <--- Place here.
    log_error = "mysql_error.log"
    

    https://community.apachefriends.org/f/viewtopic.php?f=16&t=47656

    Also, you'll want to be sure that you have your database populated with the proper time zone names if you are going to use "America/Los_Angeles". I'd recommend using the offset. I'd actually recommend using UTC as your base then converting your time from that point for users based on their timezone which will save you many headaches later and keep your database nice and uniform. Check out the guide I linked below it explained it very clearly for me and I utilized this system. There are many ways to code it but taking this approach will save you a lot of issues.

    http://www.vertabelo.com/blog/technical-articles/the-proper-way-to-handle-multiple-time-zones-in-mysql

提交回复
热议问题