Jump to content

Archived

This topic is now archived and is closed to further replies.

Sheep

time()

Recommended Posts

Hello,

When I use my time() function, it returns the time of one hour ago... Can anyone tell how this can be solved? I use the Apache server....

Greetz,
Vincent

Share this post


Link to post
Share on other sites
Your servers clock is not set correctly, I'm not sure how you'd adjust this with Apache, but you can add an hour onto your time() like this...
[code]<?php
$plusonehour = time() + (60 * 60);
echo "Now: ".date("H:i:s")."<br/>";
echo "+1Hr: ".date("H:i:s",$plusonehour);
?>[/code]

Share this post


Link to post
Share on other sites
Check your system time. The time function returns the current time of the server it is on. I am not farmiliar with apache, but does apache have it's own internal clock???

If you cannot find it you could use this to adjust it

[code]<?
// get current server time
$servtime = time();
// get required offset in seconds
$offset = 60*60;  //60*60 = 3600 seconds or 1 hour
// put them together
$currenttime = $servtime + $offset;
// Format it to your liking
$formatted_time = date("m/d/Y H:i:s", $currenttime);
// Echo it out
echo $formatted_time;
?>[/code]

Damn!! Apoc beat me to it :)

Ray

Share this post


Link to post
Share on other sites
It is my local machine(localhost)... my Windows clock is set correctly, but the time() function gives back one hour earlier...

Share this post


Link to post
Share on other sites

×

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.