Jump to content

Time zone Problem


sniperscope

Recommended Posts

Hi

My code was working perfectly when my hosting company located in Japan. But i transfer to US(hostgator) and now my time zone changes asia/tokyo to America/Chicago. Therefore, all my codes, scripts and sites are following one day behind of Japan local time.

Great appreciate for any help. My code is below:

 

<?php

$host	= "localhost";
$user	= "user";
$pass	= "pass";
$data	= "mysql_db";

$cn     = mysql_connect($host, $user, $pass) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($data, $cn) or die("Could not Connect Database Please Try again later !!!");	
mysql_query("set names utf-8", $cn);

if(date("H:i:s") < '03:00:00') // Changes midnight 00:00:00 to 03:00:00
    	     $midnight = 1;
else
    	     $midnight = 0;

       $TODAY__ = mktime(0, 0, 0, date("n"), date("d") - $midnight, date("Y"));	
       date_default_timezone_set('Asia/Tokyo');
?>

Link to comment
https://forums.phpfreaks.com/topic/220306-time-zone-problem/
Share on other sites

i want to reset it for tokyo time.

Because my database stored date for japanese local time. And now all my time is 15 hours behind schedule.

 

Example: i store some data which should display at 2010/12/01 11:47:00 at japan time(Current time in Tokyo). But Chicago is 2010-11-30 20:48:00. So, based on this difference i have to wait 15 hours to display data which means data will be useless.

Link to comment
https://forums.phpfreaks.com/topic/220306-time-zone-problem/#findComment-1141648
Share on other sites

I figured out that

date("y-n-m H:i") gives me exact tokyo time.

 

But this code gives me 15 hours behind Chicago time. Why is this happening? Why i have two different time at same host at same time.

 

 

if(date("H:i:s") < '03:00:00') // Changes midnight 00:00:00 to 03:00:00
     $midnight = 1;
else
     $midnight = 0;

$TODAY__ = mktime(0, 0, 0, date("n"), date("d") - $midnight, date("Y"));

 

 

Link to comment
https://forums.phpfreaks.com/topic/220306-time-zone-problem/#findComment-1141650
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.