Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Australia/Sydney timezone offset in javascript/nodejs?

Based on the daylight time, Austalia/Sydney timezone offset (UTC to AEST difference) is +10:00 (from April first Sunday) and +11:00 (from October first Sunday).

The difference is 600 minutes or 660 minutes.

How to get the time difference in javascript/nodejs/momentjs ? Irrespective of server time?

like image 606
Udhaya Avatar asked May 29 '26 12:05

Udhaya


1 Answers

It is very easy with Moment JS. You can try different options from Docs

var Apr = moment("2020-04-05").tz("Australia/Sydney").format('Z');
var Oct = moment("2020-10-04").tz("Australia/Sydney").format('Z');
    
console.log("Difference from April first Sunday",Apr);
console.log("Difference from October first Sunday",Oct);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.4.1/moment-timezone-with-data-2010-2020.min.js"></script>
like image 193
Nidhi Dadiya Avatar answered Jun 01 '26 03:06

Nidhi Dadiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!