Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.