Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RN v2.20.00 - All Issues
Author Message
Gremmie
Former Moderator in Good Standing


Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Mon Mar 03, 2008 9:37 am Reply with quote

This isn't specific to RavenNuke. I switched servers recently, and this morning I realized the Comments modules was showing weird times for the forum posts. And the news stories on the home page had funny times.

Both of these things call formatTimestamp() in mainfile.php. I noticed that there was a

$time -= date('Z');

in that function which is apparently some way to put in a correction for time zones. I thought about this for a minute and it doesn't make sense for me. If times are being saved in the database as local server time, why apply a correction when you display them? I commented this line out and now my time stamps look correct for my server's timezone.

Maybe it has always been this way and I never noticed it, lol. But most likely it has something to do with me changing servers. Any thoughts on this?

_________________
Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module 
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17086

PostPosted: Tue Mar 04, 2008 3:26 pm Reply with quote

I may be missing your point, but I prefer to see the dates in my time zone and not the server's.
 
View user's profile Send private message
Gremmie
PostPosted: Tue Mar 04, 2008 6:27 pm Reply with quote

The correction it is applying (-date('Z')) is correcting for the server's timezone, not the users. It isn't looking up the users timezone and correcting for that. It looks weird to me now.
 
Gremmie
PostPosted: Sun Mar 09, 2008 3:33 pm Reply with quote

I'm still confused by this. When a story is added to the queue, it uses the MySQL NOW() function for date and time. So that is inserting the current server time into the database. So when it is pulled out for display, why subtract off the server time zone correction? Especially when _DATESTRING includes %Z, the time zone indication?

Weird, it's been in there since day 1.

Code:


function formatTimestamp($time) {
    global $datetime, $locale;

    static $localeSet;     // setlocale() can be expensive to call; only need to call it once
    if (!isset($localeSet)) {
        setlocale(LC_TIME, $locale);
        $localeSet = 1;
    }

    if (!is_numeric($time)) {
        preg_match('/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/', $time, $datetime);
        $time = gmmktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]);
    }
    //$time -= date('Z');
    $datetime = strftime(_DATESTRING, $time);
    $datetime = ucfirst($datetime);
    return $datetime;
}
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RN v2.20.00 - All Issues

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©