Welcome to Geeklog, Anonymous Thursday, November 28 2024 @ 04:32 pm EST
Geeklog Forums
time zone settings
Temporalis
Anonymous
Apart from the prob of being unable to vote on polls at the moment, there's the other prob of time zone settings, i'd like it to display GMT although the server is on EST.
I'm new to this stuff, but the ease at which i've been able to configure and modify GL has impressed me greatly.
Thanks in advance.
19
23
Quote
Status: offline
jlhughes
Forum User
Full Member
Registered: 04/25/02
Posts: 154
In lib_common.php is a function called
function COM_getUserDateTimeFormat($date='')
The time is determined by calls to the PHP function time(), which returns the number of seconds from the Unix epoch for the sever time. In my case, I need to change from EST to PST.
What I've done is subtract 10800 seconds (3 hours of seconds) from the time() in three places in the function:
if (empty($date)) {
// Date is empty, get current date/time
$stamp = time()-10800;
} else if (is_numeric($date)) {
// This is a timestamp
$stamp = $date-10800;
} else {
// This is a string representation of a date/time
$stamp = strtotime($date);
$stamp = $stamp-10800;
}
The only problem is that the date format set in the config.php has $Z for time zone at the end of the date format. Since I don't know how to adjust that, I removed the $Z. The line in config.php now looks like:
$_CONF['date'] = '%A, %B %d %Y @ %I:%M %p';
This works for the date displayed in the header and for the date when articles are created. It DOES NOT change the system date that is reported when users log out of the system.
I just did this tonight and so I haven't had a chance to see yet if there will be any unexpected consequences of this hack.
13
20
Quote
Status: offline
jlhughes
Forum User
Full Member
Registered: 04/25/02
Posts: 154
OK, I've figured out why the times in the calendar got messed up. If anyone knows how to get the timezone to display correctly, I'd love to hear about it.
Anyway here's what I've changed in lib_common.php in the function COM_getUserDateTimeFormat($date='')
//Subtracting seconds from time() to shift
//time zone from server to local zone
//in this case shift is 10800 seconds or 3 hours
if (empty($date)) {
// Date is empty, get current date/time
// This is used for displaying date/time page loaded
$stamp = time()-10800;
} else if (is_numeric($date)) {
// This is a timestamp
// This is used to display story creation dates
$stamp = $date-10800;
} else {
// This is a string representation of a date/time
// This is used to translate stored calendar info
// into date format. DON'T subtract here.
$stamp = strtotime($date);
}
I've checked the page load date-time, the story creation date-time and the calendar events. All work as desired now, displaying local (Pacific) time for Geeklog running on server on East Coast.
This DOES NOT change system message times, which I believe are being created by the mySql calls.
20
23
Quote
Status: offline
jlhughes
Forum User
Full Member
Registered: 04/25/02
Posts: 154
The basic idea is the same: subtract 10800 seconds or 3 hours. The question is where.
What I've done is searched all of the Geeklog files for time(), which is the function that returns the server Unix time stamp. At every place where the function is used by itself to set a variable I have subtracted the seconds for my time zone.
For instance, in the function COM_getUserDateTimeFormat($date='')
//Subtracting seconds from time() to shift
//time zone from server to local zone
//in this case shift is 10800 seconds or 3 hours
if (empty($date)) {
// Date is empty, get current date/time
// This is used for displaying date/time page loaded
$stamp = time()-10800;
} else if (is_numeric($date)) {
// This is a timestamp
// This date variable should already have been adjusted
// in the calling page
$stamp = $date;
} else {
// This is a string representation of a date/time
// This is used to translate stored calendar info
// into date format. DON'T subtract here.
$stamp = strtotime($date);
}
The time() function is called in lib_common.php, comment.php, pollbooth.php, submit.php, admin/users.php, admin/event.php, admin/story.php and calendar.class
By changing =time() to =time()-10800 in the appropriate areas (NOT where time() is already adjusted by other variables), I've been able to shift the time zone for my site.
The only place where this DOES NOT work is with times derived from Geeklog's interaction with mySql. The logout "System message" reports the server time.
Also, articles that must be approved are dated with the mySql server time. (The admin-level articles, where the user can adjust the publication date/time, show the adjusted time AND store that adjusted time.)
For the record, this is ONLY necessary because my site is designed to be used solely by people who live in one time zone; for sites with a broader audience, it makes no sense to go to this much trouble.
John Hughes
34
33
Quote
rekcah5
Anonymous
Instead of deleting the %Z from the $_CONF['date'] can't you just replace the %Z to your time zone for instance this is what I have:
$_CONF['date'] = '%A, %B %d %Y @ %I:%M %p MST';
It seems to work.
18
18
Quote
jthompson
Anonymous
I know this is an old thread but I found an EZ solution for this problem.
Just add the:
putenv("TZ=America/New_York"
line to your config.sys file. I put it above the:
$_CONF['language'] = 'english';
line. The link below has another link of all available time zones.
Here is where I found the info:
http://www.modwest.com/help/kb5-258.html
Hope this helps someone.
Just add the:
putenv("TZ=America/New_York"
line to your config.sys file. I put it above the:
$_CONF['language'] = 'english';
line. The link below has another link of all available time zones.
Here is where I found the info:
http://www.modwest.com/help/kb5-258.html
Hope this helps someone.
13
16
Quote
All times are EST. The time is now 04:32 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content