johnnyk Posted July 8, 2006 Share Posted July 8, 2006 I've asked this question before but have never gotten an answer:So I want to set the timezone for MySQL. mysql.org says I should use this:mysql> SET GLOBAL time_zone = timezone;But what do I do with that? I tried inserting it into .htaccess and I tried using mysql_query(SET GLOBAL time_zone = timezone;) in PHP, but neither worked. What do I do? Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/ Share on other sites More sharing options...
Daniel0 Posted July 9, 2006 Share Posted July 9, 2006 In the shell, if you use Linux, you could do something like this: [code]daniel@daniel:~$ mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 36 to server version: 5.0.22-Debian_0ubuntu6.06-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> SET GLOBAL time_zone = '+1:00';[/code]Or in PHP you could do it in this way: [code]<?php$link = mysql_connect("localhost","root","password");mysql_query("SET GLOBAL time_zone = '+1:00';");?>[/code]These examples will set the timezone to GMT+1 (CET). Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/#findComment-55176 Share on other sites More sharing options...
johnnyk Posted July 9, 2006 Author Share Posted July 9, 2006 It's not working. No errors or anything, but it doesn't change the timezone.Also, what does it mean to set it to GLOBAL? What would it do differently? Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/#findComment-55272 Share on other sites More sharing options...
fenway Posted July 10, 2006 Share Posted July 10, 2006 Assuming you're logged in as MySQL root, there should be no reason why the timezone isn't changing, unless your my.cnf file says otherwise. GLOBAL is as opposed to SESSION, which only affects the current connection. Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/#findComment-55341 Share on other sites More sharing options...
johnnyk Posted July 10, 2006 Author Share Posted July 10, 2006 2 questions:-How do I view the my.cnf file (I'm using a hosting company, mysql isn't on my computer)-So if I use GLOBAL, do I only need to do it once ever, and never include it with any page with queries? Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/#findComment-55393 Share on other sites More sharing options...
fenway Posted July 10, 2006 Share Posted July 10, 2006 Most likely your hosting company won't let you edit it... you'd have to check with them. GLOBAL is global for the server, but won't survive a restart, AFAIK. Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/#findComment-55635 Share on other sites More sharing options...
johnnyk Posted July 11, 2006 Author Share Posted July 11, 2006 I don't understand what GLOBAL does then? Does it keep the timezone for the session or something? Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/#findComment-55942 Share on other sites More sharing options...
fenway Posted July 11, 2006 Share Posted July 11, 2006 GLOBAL is across sessions, SESSION is per session. Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/#findComment-56054 Share on other sites More sharing options...
johnnyk Posted July 11, 2006 Author Share Posted July 11, 2006 [quote]GLOBAL is global for the server, but won't survive a restart, AFAIK.[/quote]Do you mean a server restart? Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/#findComment-56337 Share on other sites More sharing options...
fenway Posted July 12, 2006 Share Posted July 12, 2006 Correct. Quote Link to comment https://forums.phpfreaks.com/topic/14062-set-timezone/#findComment-56578 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.