darkcarnival Posted November 10, 2006 Share Posted November 10, 2006 hi,im working on a project and the thing I want to do is add support for DST(daylight saving time)I know vb uses this and a few othres do too but how do you actually detect dst?thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/26880-dst-detection/ Share on other sites More sharing options...
Psycho Posted November 11, 2006 Share Posted November 11, 2006 Not sure what you mean by "how do you actually detect dst"if you are talking about detecting DST on the user end, then you can't - unless you were to ask them if they observe DST and you were to save that value for whenever you wanted to show that person a time.On the server end you can use gettimeofday() which will return an array. one of the array values is "dsttime" - type of dst correction. That might be what you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/26880-dst-detection/#findComment-122941 Share on other sites More sharing options...
darkcarnival Posted November 11, 2006 Author Share Posted November 11, 2006 yes thats what im asking for.looking at the php manual, it doesnt give much on how to use it, any ideas on how to use it for the purpose i want it for? Quote Link to comment https://forums.phpfreaks.com/topic/26880-dst-detection/#findComment-122972 Share on other sites More sharing options...
Monkeymatt Posted November 11, 2006 Share Posted November 11, 2006 From http://php.net/date:[quote]I (capital i) Whether or not the date is in daylight saving time 1 if Daylight Saving Time, 0 otherwise.[/quote]Monkeymatt Quote Link to comment https://forums.phpfreaks.com/topic/26880-dst-detection/#findComment-122985 Share on other sites More sharing options...
Psycho Posted November 11, 2006 Share Posted November 11, 2006 The data function, as Monkeymatt showed, will tell you if a given date is within the daylight savings period.Usage is like this: $dst = date('I', [i]timestamp[/i]);$dst will be equal to 1 if the date is within the DST period or 0 if it is not.The gettimeofday() function returns an array and one of the values will tell you if the server observes DST and another will tell you what the DST adjustment is for the server. Usage is as follows:$timearray = gettimeofday90;$dstobserve = = $timearray[dsttime]; // 0 or 1$dstadjustment = $timearray[minuteswest]; //adjustment from standard time Quote Link to comment https://forums.phpfreaks.com/topic/26880-dst-detection/#findComment-123019 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.