Jump to content

Recommended Posts

<?php
function set_timezone($timezone="0"){
switch($timezone){
  case "-12": date_default_timezone_set('Etc/GMT+12'); break;
  case "-11": date_default_timezone_set('Etc/GMT+11'); break;
  case "-10": date_default_timezone_set('Etc/GMT+10'); break;
  case "-9": date_default_timezone_set('Etc/GMT+9'); break;
  case "-8": date_default_timezone_set('Etc/GMT+8'); break;
  case "-7": date_default_timezone_set('Etc/GMT+7'); break;
  case "-6": date_default_timezone_set('Etc/GMT+6'); break;
  case "-6": date_default_timezone_set('Etc/GMT+5'); break;
  case "-4": date_default_timezone_set('Etc/GMT+4'); break;
  case "-3": date_default_timezone_set('Etc/GMT+3'); break;
  case "-2": date_default_timezone_set('Etc/GMT+2'); break;
  case "-1": date_default_timezone_set('Etc/GMT+1'); break;
  case "0": date_default_timezone_set('GMT'); break;
  case "1": date_default_timezone_set('Etc/GMT-1'); break;
  case "2": date_default_timezone_set('Etc/GMT-2'); break;
  case "3": date_default_timezone_set('Etc/GMT-3'); break;
  case "4": date_default_timezone_set('Etc/GMT-4'); break;
  case "5": date_default_timezone_set('Etc/GMT-5'); break;
  case "6": date_default_timezone_set('Etc/GMT-6'); break;
  case "7": date_default_timezone_set('Etc/GMT-7'); break;
  case "8": date_default_timezone_set('Etc/GMT-8'); break;
  case "9": date_default_timezone_set('Etc/GMT-9'); break;
  case "10": date_default_timezone_set('Etc/GMT-10'); break;
  case "11": date_default_timezone_set('Etc/GMT-11'); break;
  case "12": date_default_timezone_set('Etc/GMT-12'); break;
}
}

set_timezone('+10');
?>

and voila! your server thinks its in sydney! lol

Link to comment
https://forums.phpfreaks.com/topic/51638-solved-time-and-date/#findComment-254370
Share on other sites

So i'm looking for:

 

date_default_timezone_set('Etc/GMT-10');

 

Is there anywhere special, like just before I use time/date or perhaps just call it the once at the top of pages that make use of time and date?

 

Woah, I didn't realise you could use case statements in PHP lol dang, I could have been using these....... :P

Link to comment
https://forums.phpfreaks.com/topic/51638-solved-time-and-date/#findComment-254371
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.