Problems with time and date.
Posted: Tue Apr 08, 2003 6:52 pm
OK from my brief poke around this forum with search, I can tell there are many here who do not like PHP-Nuke, but my question reguards it. I have a few blocks in Nuke that get the time and date from the server machine directly. Here's the problem. My site is hosted on a server in Hong Kong, most of our members are in the central timezone of the US. How can I make the code reflect the 13 hour difference. Here is the code from one such problem. It can be seen "in action" at http://www.pararc.org
I have tried asking this in the most used PHP-Nuke forums as well, but none have turned a result. Most tell me there is major issues with the International Date Line.
Any help would be greatly appreciated. This has been a thorn in my side for a long time.
Code: Select all
<?php
########################################################################
# PHP-Nuke Block: Total Hits v0.1 #
# #
# Copyright (c) 2001 by C. Verhoef (cverhoef@gmx.net) #
# #
########################################################################
# This program is free software. You can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License. #
########################################################################
# Server Date/Time added by: #
# Nuke Scripts Network (http://www.nukescripts.com) #
########################################################################
if (eregi("block-Total_Hits.php", $PHP_SELF)) {
Header("Location: index.php");
die();
}
global $nukeurl, $prefix, $startdate, $dbi;
/* Hits for Today */
$t_time = time();
$t_year = date("Y", $t_time);
$t_month = date("n", $t_time);
$t_date = date("j", $t_time);
$result = sql_query("SELECT hits FROM $prefix"._stats_date." WHERE year='$t_year' AND month='$t_month' AND date='$t_date'", $dbi);
list($today) = sql_fetch_row($result, $dbi);
/* Hits for Yesterday */
$y_time = $t_time - 86400;
$y_year = date("Y", $y_time);
$y_month = date("n", $y_time);
$y_date = date("j", $y_time);
$result = sql_query("SELECT hits FROM $prefix"._stats_date." WHERE year='$y_year' AND month='$y_month' AND date='$y_date'", $dbi);
list($yesterday) = sql_fetch_row($result, $dbi);
/* Hits in Total */
$totalhits = 0;
$result = sql_query("SELECT hits FROM $prefix"._stats_year."", $dbi);
while(list($hits) = sql_fetch_row($result, $dbi)) {
$totalhits = $totalhits + $hits;
}
$content = "<center><small>"._WERECEIVED."</small><br>\n";
$content .= "<b><a href="modules.php?name=Statistics">$totalhits</a></b><br>\n";
$content .= "<small>"._PAGESVIEWS."<br>$startdate</small></center>";
$content .= "<hr noshade>";
/*$content .= "<center><b><u>..:"._BLATEST." "._BHITS.":..</u></b><br>";*/
$content .= "<center>"._BHITS." "._BTD.": <b><a href="modules.php?name=Statistics&op=DailyStats&year=$t_year&month=$t_month&date=$t_date">$today</a></b><br>";
$content .= ""._BHITS." "._BYD.": <b><a href="modules.php?name=Statistics&op=DailyStats&year=$y_year&month=$y_month&date=$y_date">$yesterday</a></b><br></center>";
/*
$content .= "<hr noshade>";
$sdt = date("F j Y\nH:i:s T");
$zone = date("Z")/3600;
if ($zone >= 0) {
$zone = "+".$zone;
}
$std = strftime ("%e %B %Y<br>%T %Z");
$content .= "<center>"._SERDT."<br>$sdt (GMT $zone)</center>";
*/
?>Any help would be greatly appreciated. This has been a thorn in my side for a long time.