First I just want to say how much I LOVE Gallery. Took me a bit to figure it all out, but now that I have it up and running, it's awesome! :smile:
A question - I've found most of the things I wanted to change by poking around in the Gallery files, but the one thing that's eluded me is how to change the time on the comments to reflect my time zone (PST) instead of what it's showing (CDT). Is that something I can change easily or not?
Thanks!
Posts: 22
Gallery seems to use php's date function, which will output the time zone used wherever the server is located (Central Time in your case).
You could modify classes/Comment.php to adjust this, but it will always be wrong to someone :smile:
I have seen some Javascipt code that will use the users local time, but this is not a simple change.
Code from Comment.php:
return date("M d, Y H:i T", $time);
This <!-- BBCode Start --><A HREF="http://groups.google.com/groups?num=100&hl=en&lr=&ie=ISO-8859-1&q=change+time+zone+in+php+group%3A*php*" TARGET="_blank">Google Search</A><!-- BBCode End --> may shead some light on your situation.
no easy fix for this one, sorry.
muggles
Posts: 1301
Hi there
Thanks for the answer --I suspected as much (that it was tied into my server location). I don't think I'll worry about it too much since that's the case, but I will look thru the links in the google search you provided (much appreciated)!
Regards,
Posts: 34
yeah, unfortunately because Gallery doesn't include a profile system with information such as their time zone you're a bit stuffed in this respect.
Posts: 39
I guess that is referring to an older version of gallery as there is no comment.php in mine :/ (1.3.1)
Where abouts is it now? (The date/time output line.) Having no luck finding it yet..
Posts: 39
How I've adjusted it to GMT:
Edited the file classes/Comments.php
Where it states:
$this->datePosted = time();
In the block of code:
function Comment($commentText, $IPNumber, $name, $UID="") {
$this->commentText = $commentText;
$this->datePosted = mktime();
$this->IPNumber = $IPNumber;
$this->name = $name;
$this->UID = $UID;
}
I changed this to:
$this->datePosted = mktime();
Then where is says:
return date("M d, Y H:i T", $time);
In the block of code:
function getDatePosted() {
$time = $this->datePosted;
return gmdate("M d, Y H:i T", $time);
}
I changed it to:
return gmdate("M d, Y H:i T", $time);
This solved my problem of my website being hosted in the US while I'm in England and so displaying the time there and not here :grin:
Hope that helps someone!
Posts: 4
Yes, the above works! It even adjusts comments that have already been posted. Thanksmichellez!
Posts: 3474
Hmm... we could use PEAR's Date package for this (obviously checking if it's installed first). It would allow the option of setting a local time either for the whole site, or for individual users...
Posts: 12
The quick oneoff I used, since I can almost guarantee most folks will be coming from eastern, is the following:
If there's a way to use javascript to determine the user's timezone, this would be even cooler. You know, browsers really should send the timezone as part of the GET or POST request so the server knows where they are easily ;)
-P
Posts: 3474
I've added a plan for v1.4.1 to add two items to Gallery:
1) Main configuration allows timezone offset (in case your server doesn't match). Drop-down for time offset.
2) Add the same thing to the user preferences, so each user can set her/his own timezone.
I want to shy away from detecting specific timezones (EDT, etc.) since we can't always tell whether the server is set to local time, or to GMT, or UTF.
Comments, thoughts about the best thing to do for the Gallery codebase?
Posts: 12
From an algorithmic perspective, frankly it doesn't matter if the server is in martian time -- as long as it's true to itself (if the admins change system time frequently, this method will suck, but then again, so will everything else).
I suggest that you store the timestamp in epoch time from the server's perspective, and when people hit the site, use javascript to get what **they** think the local time is on their remote machine. Compare it to what's on the server at that moment, create an offset, and add or subtract that from what the server thinks the time was when the comment was created, or picture added, or anything else that you're tracking time for. That way, it will always be correct relative to the user's computer.
The benefit here is that obviously, there's no database for each user's timezone, it's always correct relative to the computer you're on, and you don't need to be logged in If I fly to across the country, it will still seem right, as long as the machine I'm on has the right time ;)
-P
Posts: 3
I can't seem to find any server offset in the config or any further discussion on this in the forums...
This is of particular importance to me as I'm in Australia, but hosted in the US. So there's about a 17 hour time difference (depending on daylight saving) which means nearly all albums say they are posted the day before they actually were. Likewise comment time stamps are totally shot.
Any solution to this?
Thanks
Posts: 3474
This never got finished.
Actually, this never got started either. :roll: I'll see if I can resurrect it somewhat on the feature todo list, but it's likely it won't get done soon unless someone jumps in and implements it...
-Beckett (
)
Posts: 4
My website host won't change the timezone TZ variable for the site (I think the support folks don't know how), so the following one line addition to gallery/Comment.php file changes the TZ variable for Gallery's comment:
This works for the comment displayed when viewing a picture. There may be more places in Gallery that would benefit from the proper timezone setting.
Does anyone have a better place to putenv() TZ so that it would take effect for all of Gallery? This solution seems rather hacky.
Khoa
Posts: 15
Any idea how to resolve the time zone inssue in G2?
Thanks in advance/Frank
Posts: 27300
duvide,
post in the G2 forums as well as make a bug report or a RFE in the SF pages.