johnnyk Posted June 26, 2006 Share Posted June 26, 2006 How would I set something like a timezone or mode in MySQL with PHP?Mysql.org says to use something likemysql> SET time_zone = timezone;But what do you do for PHP? I triedmysql_query("SET time_zone = timezone");but that didn't work.While we're at it, what does it mean to set something as GLOBAL? Quote Link to comment https://forums.phpfreaks.com/topic/12967-mysql-set/ Share on other sites More sharing options...
redarrow Posted June 26, 2006 Share Posted June 26, 2006 this method sets the system timezone for the current script, and returns the previous timezone.[code]<?php function setTimezone($timezone) { $oldTz = getenv('TZ'); putenv('TZ=' . $timezone); return $oldTz; }?>Sample usage:Highlight: PHP<?php $newTz = 'Australia/Adelaide'; $oldTz = setTimezone($newTz); echo "The old timezone was " . $oldTz . " and the new timezone is " . $newTz;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12967-mysql-set/#findComment-49851 Share on other sites More sharing options...
johnnyk Posted June 27, 2006 Author Share Posted June 27, 2006 But that doesn't affect MySQL's NOW()I'm talking about [a href=\"http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.0/en/tim...ne-support.html[/a]How do I set MySQL's timezone in PHP. The above page says you should usemysql> SET time_zone = timezone;but how do you do that in PHP?Also, what is the difference between that andmysql> SET GLOBAL time_zone = timezone; Quote Link to comment https://forums.phpfreaks.com/topic/12967-mysql-set/#findComment-49919 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.