php - How to tell if a timezone observes daylight saving at any time of the year? -


In PHP, you can tell that the given date is using something like this during daylight saving time period :

$ isDST = date ("I", $ myDate); // 1 or 0

The problem is that it only tells you whether a point in time is in DST or not. Is it a reliable way to check whether DST is in effect at any time in that time zone?


Edit to clarify:

  • Brisbane, Australia does not observe daylight saving at any time of the year. Nearby all year, this is GMT + 10.
  • Sydney, Australia from October to March, when it changes from GMT + 10 to GMT + 11

I 'm thinking whether there will be any existing method, or there is a way to implement the method that works like this:

  Timezondos DST ('Australia / Brisbane'); // False Timezone Dozest Dest ('Australia / Sydney'); I have found a way to work using PHP's DataTimeZone Class (PHP) I / O true  

5.2 +)

  Function timezondos dst ($ tzId) {$ tz = new datetime timezone ($ tzId); $ Trans = $ tz- & gt; GetTransitions (); Return ((count ($ trans) and amp; $ trans [count ($ trans) - 1] ['ts'] & gt; time ())); Or, if you are running Php 5.3 + /  
  Function TimezoneDoice DST ($ tzId) {$ tz = New DateTimeZone ($ tzId) ; Calculation of return ($ tz-> getTransitions (time ())) gt; 0; } The  

function gives you information about the offset change for the time zone, it includes historical data (Brisbane had saved daylight in 1916 .. who knows Was?) , so this function checks either offset changes in the future.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -