PDA

View Full Version : date() changes at 7pm insteam of 12am


grudz
02-07-2005, 05:03 PM
Hello,

I'm using a standard date function on a website <?php echo date("l, F j, Y"); ?> yet every night at 7pm it'll say that it's the next day.

For example, tonight, at 7pm; instead of saying Monday, February 7, 2005, it'll say Tuesday, February 8, 2005....

any ideas why?

Thank you

marek_mar
02-07-2005, 05:12 PM
The server must not be in your timezone. He may have a different time.

grudz
02-07-2005, 05:18 PM
so what can i do? any way around it?

marek_mar
02-07-2005, 06:03 PM
Well you could try this:

print date("l, F j, Y", time() - $your_timezone_offset);

$your_timezone_offset is the difference in time from the server to you. So if the server in in the GMT timezone 0 and you are in -7 you should add 7*3600 to the server time.

grudz
02-07-2005, 09:31 PM
that's weird.....i just contact my server and they are in the same time zone as me?

Hawkmoon
02-07-2005, 09:49 PM
Use this script to test the server time with the local time on your computer.

-Hawkmoon


<html>
<head>
<script language="JavaScript">
function get_time() {
var objDate = new Date();
document.getElementById("current_time").innerHTML = "<b>Local Time: </b>" + objDate;
}
</script>
</head>
<body onLoad="get_time()">
<?php
print "<b>Server Time:</b> " . date("D M j H:i:s T Y", time());
?>
<div id="current_time"></div>
</body>
</html>