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
https://forums.phpfreaks.com/topic/253047-change-timezone/#findComment-1297356
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
https://forums.phpfreaks.com/topic/253047-change-timezone/#findComment-1297358
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.