Search code examples
phptimezoneoffsetdst

Get current Timezone offset from offset saved before daylight started


I have saved utc date with client timezone offset as -570 of australia/adelaide which was offset before DAY LIGHT SAVING STARTED . Now I need to find the current offset using -570 after daylight saving has started using php code? Is there any way to achieve this?


Solution

  • If you stored -570 (meaning UTC+09:30), and did not store "Australia/Adelaide", then no - there is no way to determine this. It doesn't matter which programming language you are using.

    The reason is simply that while South Australia (represented by Australia/Adelaide) switches between UTC+09:30 and UTC+10:30 for daylight saving time, Northern Territory (represented by Australia/Darwin) uses UTC+09:30 the entire year.

    If you happened to have a timestamp during the summer period that was associated with UTC+09:30, then you could reasonably assert that it was associated with Australia/Darwin - but only because it happens to be the only one observing that offset during that time. The same cannot be said for a timestamp during the winter period, or for the general case worldwide.

    In other words, -570 might refer to either Australia/Adelaide or Australia/Darwin.

    Or it might even refer to Yancowinna county of New South Wales (represented by Australia/Broken_Hill), which follows Adelaide instead of the rest of NSW.

    See also "Time Zone != Offset" in the timezone tag wiki, and Time in Australia on Wikipedia.