Jump to content

Can someone help correct this function.


Perad

Recommended Posts

- Top of the page -

In my actual script.

[code]$postdate = strtotime($dbentry['postdate']);
$date = date('j F Y, g:i a', $postdate); //Currently does very little
$date = timezone($date);[/code]

My function
[code]
function timezone($date) {
global $userdata;

$timezone = $userdata['user_timezone'];
$serverTime = "1.0";
$difference = ($timezone - $serverTime);

$date -= ($difference * 3600);

$ourTime = date('d/m/Y h:i:s',$date);
echo $ourTime;
}[/code]

The function is supposed to take the date variable and convert it to the users timezone. Currently when i run it, there are no errors but the output is the 1/1/1970 time, instead of the current time +/- an hour.

$timezone is a decimal 1.0, 2.0, based on how far ahead or behind GMT the user is.
Link to comment
https://forums.phpfreaks.com/topic/35544-can-someone-help-correct-this-function/
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.