sniperscope Posted December 1, 2010 Share Posted December 1, 2010 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'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/220306-time-zone-problem/ Share on other sites More sharing options...
jcbones Posted December 1, 2010 Share Posted December 1, 2010 So you want it reset to Tokyo time? OR, you want it set to Chicago time? You aren't real clear on what you want. Quote Link to comment https://forums.phpfreaks.com/topic/220306-time-zone-problem/#findComment-1141644 Share on other sites More sharing options...
sniperscope Posted December 1, 2010 Author Share Posted December 1, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/220306-time-zone-problem/#findComment-1141648 Share on other sites More sharing options...
sniperscope Posted December 1, 2010 Author Share Posted December 1, 2010 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")); Quote Link to comment https://forums.phpfreaks.com/topic/220306-time-zone-problem/#findComment-1141650 Share on other sites More sharing options...
sniperscope Posted December 1, 2010 Author Share Posted December 1, 2010 is that help me to add +54000(15hours) to mktime? Quote Link to comment https://forums.phpfreaks.com/topic/220306-time-zone-problem/#findComment-1141680 Share on other sites More sharing options...
sniperscope Posted December 1, 2010 Author Share Posted December 1, 2010 Any way. I solved problem via .htaccess SetEnv TZ Asia/Tokyo I hope this solution helps someone else too. Quote Link to comment https://forums.phpfreaks.com/topic/220306-time-zone-problem/#findComment-1141743 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.