timezone(?) problem
Posted by: vrlk (---.02-2011-756d651.cust.bredbandsbolaget.se)
Date: February 28, 2008 04:29PM

Hi, i got this annoying problem with apache/php..

date('H',time()); shows as one hour behind my time, eventhough the clock in windows is correct.

ive tried to put date.timezone = "Europe/Stockholm" in php.ini without success.


anyone know why this is and how to fix it?

thanks.

Options: ReplyQuote
Re: timezone(?) problem
Posted by: vrlk (---.02-2011-756d651.cust.bredbandsbolaget.se)
Date: February 28, 2008 10:28PM

anyone?
close to shooting myself ;x

Options: ReplyQuote
Re: timezone(?) problem
Posted by: hambuler (---.cpe.net.cable.rogers.com)
Date: February 29, 2008 05:33AM

Try date("H"winking smiley.

Options: ReplyQuote
Re: timezone(?) problem
Posted by: vrlk (---.02-2011-756d651.cust.bredbandsbolaget.se)
Date: March 02, 2008 03:09AM

i dont see how that could help me tbh ;E

anyway, found a semi ok fix.. putenv("TZ=Europe/Stockholm"winking smiley;

i would rather have that as a global setting though.

Options: ReplyQuote
Re: timezone(?) problem
Posted by: toivo (203.19.130.---)
Date: March 02, 2008 10:55AM

Hi,

Global settings are up to your application, depending on where your users are, I think. Not every one of them have to be in the same timezone - om de är inte i Sverige allena :-)

Your application may be able to grab the timezone from the browser settings using some nifty javascript, I assume.

Vänliga hälsingar,

toivo
Sydney, Australia



Edited 1 time(s). Last edit at 03/02/2008 10:58AM by toivo.

Options: ReplyQuote
Re: timezone(?) problem
Posted by: toivo (203.19.130.---)
Date: March 02, 2008 11:35AM

Hi,

Last week I was working with MediaWiki ( see [www.mediawiki.org] ) and this thread reminded me how MediaWiki prompts for the timezone in the user preferences, displaying the server time, the local time and the Offset. The Offset field [ name='wpHourDiff' id='wpHourDiff' ] has the button underneath it to 'Fill in from browser', here is the javascript how it does it through [ onclick='javascript:guessTimezone()' id='guesstimezonebutton' ]. The code is extracted from ../skins/common/wikibits.js:

function unhidetzbutton() {
var tzb = document.getElementById('guesstimezonebutton');
if (tzb) {
tzb.style.display = 'inline';
}
}

// in [-]HH:MM format...
// won't yet work with non-even tzs
function fetchTimezone() {
// FIXME: work around Safari bug
var localclock = new Date();
// returns negative offset from GMT in minutes
var tzRaw = localclock.getTimezoneOffset();
var tzHour = Math.floor( Math.abs(tzRaw) / 60);
var tzMin = Math.abs(tzRaw) % 60;
var tzString = ((tzRaw >= 0) ? "-" : ""winking smiley + ((tzHour < 10) ? "0" : ""winking smiley + tzHour +
":" + ((tzMin < 10) ? "0" : ""winking smiley + tzMin;
return tzString;
}

function guessTimezone(box) {
document.getElementsByName("wpHourDiff"winking smiley[0].value = fetchTimezone();
}


Very clever, IMHO

Regards,

toivo
Sydney, Australia

Options: ReplyQuote


Sorry, only registered users may post in this forum.