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
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?

Link to comment
Share on other sites

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

Link to comment
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.