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