Jump to content

Change timezone


waddledoo

Recommended Posts

//change timezone php
putenv('TZ=Australia/Sydney');

 

and to change it in your mysql database

//get offset, including daylight savings because mysql won't
$currentOffset = "+".(date("Z") / 60 / 60).":00";

//timezone mysql
$update_tz = @mysql_query("SET time_zone = '$currentOffset'") or die(mysql_error());

Link to comment
Share on other sites

This code:

<?php
date_default_timezone_set('Canada/mountain');  //this is on my computer; on the webhost it is unnecessary
echo date('H:i:s');
putenv('TZ=UTC');
echo "<br>";
echo date ('H:i:s');
?>

 

Is displaying this:

 

20:01:30

20:01:30

 

 

What am I doing wrong?

 

EDIT:

I don't know what the issue is on my own computer, but using the 'putenv' with the webhost works perfectly, thanks!

Link to comment
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.