Jump to content

[SOLVED] show time in local time


soycharliente

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/59131-solved-show-time-in-local-time/
Share on other sites

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?

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

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.