gmt function returns an hour less than expected result when datetime is near the Daylight Savings switch

Certified Associate Developer

We are in Adelaide, Australia and our State switched to daylight savings time last week on the 6th of October at 2:00 AM local time. We will switch back to normal Australian Adelaide Time on the 4th of April next year at 3:00 am.

The problem I have is the weird (for us anyway) behaviour of the gmt() function when the date passed is 10 and a half hours before the time of the daylight savings switch. It subtracts an hour to the result.

For example, 
gmt("15/09/2019 17:00") returns the expected answer 15/09/2019 17:00 GMT+09:30
gmt("30/09/2019 17:00") returns the expected answer 30/09/2019 17:00 GMT+09:30
gmt("05/10/2019 16:29") returns the expected answer 05/10/2019 16:29 GMT+09:30
gmt("07/10/2019 4:30") returns the expected answer 07/10/2019 04:30 GMT+10:30

But if the datetime passed is between Oct 5 2019 16:30 and Oct 6 2020 02:59, the result is an hour less:
gmt("05/10/2019 16:30") returns 05/10/2019 15:30 GMT+09:30
gmt("06/10/2019 2:20") returns 06/10/2019 01:20 GMT+09:30

Similarly, when the datetime passed is between April 4 2020 16:30 and April 5 01:59, the result is an hour more.

Is there a way to get around this gmt() function behaviour? (This also happens for the local() function the other way).

  Discussion posts and replies are publicly visible

Parents Reply Children