soycharliente Posted July 9, 2007 Share Posted July 9, 2007 I tried searching for the answer, but didn't really get anything back. Maybe it's the terminology I was using. Can anyone help me in a direction for how to change what time zone a time is displayed for? My timestamps default to California and would like to show them as EST. Or even show the time in whatever time zone the person viewing the time is in. Does that sentence make sense? Quote Link to comment Share on other sites More sharing options...
trq Posted July 9, 2007 Share Posted July 9, 2007 Or even show the time in whatever time zone the person viewing the time is in Easiest way to do that is use javascript. It uses the time on the client. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted July 9, 2007 Author Share Posted July 9, 2007 Is it possible in PHP? Quote Link to comment Share on other sites More sharing options...
trq Posted July 9, 2007 Share Posted July 9, 2007 Take a look at date_default_timezone_set. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted July 9, 2007 Author Share Posted July 9, 2007 I'm getting this error: Fatal error: Call to undefined function: date_default_timezone_set() in /index.php on line 4 For this code: date_default_timezone_set(date_default_timezone_get()); I thought it was a built-in function. EDIT: OOOH! PHP 5.0+ DOH! So what can I do with PHP 4.3.11? Quote Link to comment Share on other sites More sharing options...
marcus Posted July 9, 2007 Share Posted July 9, 2007 It's for PHP5+ Quote Link to comment Share on other sites More sharing options...
soycharliente Posted July 9, 2007 Author Share Posted July 9, 2007 Made an edit, maybe it got skipped. So what can I do with PHP 4.3.11? I found this, but it doesn't seem to work very well. It's giving me a date from like 14 hours ago. <?php $record = file("http://api.hostip.info/get_html.php?ip=". $_SERVER['REMOTE_ADDR']."&position=true"); $longitude = substr($record[3], 11); $offset = $longitude / 15; $true_local_time = gmmktime() + ($offset * 3600); //return $true_local_time; echo date('M j Y, H:m:s', $true_local_time); ?> That came from this page: http://www.expertsrt.com/tutorials/Matt/PHPTimeZone.html Quote Link to comment Share on other sites More sharing options...
per1os Posted July 9, 2007 Share Posted July 9, 2007 Are you sure that data is pulling correctly from the remote site. Do a vardump on $record. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted July 9, 2007 Author Share Posted July 9, 2007 Country: UNITED STATES (US) City: Atlanta, GA Latitude: 33.7629 Longitude: -84.4226 Quote Link to comment Share on other sites More sharing options...
soycharliente Posted July 9, 2007 Author Share Posted July 9, 2007 I just won't do it. Nevermind. Seems like too much work. Quote Link to comment 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.