Jump to content
The Uniform Server Community

changing date on server


jpgalea
 Share

Recommended Posts

You never explained why you want to do this. Apache obtains its time reference from the PC clock. In theory you could change the PC clock hence change Apache time. It is neither desirable nor a good idea to do this, will cause havoc with other programs.

 

If all you want to do is change-displayed time to a user use PHP for example:

Save this as test.php it effectively locates your server in a different time zone, however in reality it is referenced to your PC time.

 

<p>Display local time</p>
<?php print  date("H:i") ?>

<p>Display time difference + 5hours</p>
<?php
$diff_to_localtime=5;
$new_var=date("U")+$diff_to_localtime*3600;
print date("H:i", $new_var);
?>

<p>Display time difference - 5hours</p>
<?php
$diff_to_localtime=5;
$new_var=date("U")-$diff_to_localtime*3600;
print date("H:i", $new_var);
?>

<?php
putenv("TZ=America/Chicago");
?>
<p>Display local time America/Chicago </p>
<?php print  date("H:i") ?>
<br>


<?php
putenv("TZ=Australia/Melbourne");
?>
<p>Display local time  Australia/Melbourne</p>
<?php print  date("H:i") ?>
<br>

 

If you want to do is echo their local time use a small JavaScript to pick up there local PC time.

 

Not sure if that’s of any help

All the best

Ric :D

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...