Jump to content

MySQL set


johnnyk

Recommended Posts

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]
Link to comment
https://forums.phpfreaks.com/topic/12967-mysql-set/#findComment-49851
Share on other sites

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 use
mysql> SET time_zone = timezone;
but how do you do that in PHP?

Also, what is the difference between that and
mysql> SET GLOBAL time_zone = timezone;
Link to comment
https://forums.phpfreaks.com/topic/12967-mysql-set/#findComment-49919
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.