Steve wrote:
Andrew DeFaria wrote:
I have the following php code:
function Today2SQLDatetime () {
$today = date ("Y-m-d H:i:s");
print "date (\"Y-m-d H:i:s\") returned $today<br>";
return $today;
return date ("Y-m-d H:i:s");
} // Today2SQLDatetime
Most of the time this works just fine. For today, for example, it
returns "2005-02-11 xx:xx:xx". But sometimes, for some odd reason it
returns "2005-02-12 xx:xx:xx"! My theory is that since this is on my
web page and since PHP is running under Apache and since this happens
every once in a while that perhaps one of Apache's subprocess has the
wrong idea of my time zone and is actually pointed into tomorrow. Any
ideas?
Where's the server?
In the closet! ;-)
That's the time that's being returned, not the one on the computer
running your browse.
I checked that. It was the correct time AFAICT. Ah ha! This might be it:
Sometimes I seem to get a date/time that is 8 hours ahead! For example,
while date returns:
Sat Feb 12 00:09:58 PST 2005
The following sometimes returns: Current date and time is: 2005-02-12
08:09:47:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<title>Test</title>
</head>
<body>
<?php
function ReturnToday () {
return date ("Y-m-d H:i:s");
} // ReturnToday
$date = ReturnToday ();
echo "Current date and time is: $date<br>";
?>
As you know Apache starts several processes to handle requests. So I
used top to see which httpd was servicing the request that was returning
the wrong date/time and kill it. There were many other httpd processes.
Refreshed the page and wham, the date and time was correct, i.e. now
displayes Current date and time is: 2005-02-12 00:14:15.
I guess this becomes a question of where does Apache get it's notion of
what timezone you are set to?
--
A mainframe: The biggest PC peripheral available.