I am using moment-timezone
for working with timezones in Node.js
. I am wondering if there is a way to get the current timezone (file) version being used. For example, the latest IANA version at the time of writing this is 2021a
.
I need to know this, so that I can update dateTimes in my database whenever a new version is released.
I read through all of the documentation, but I couldn't find it...
You can use moment.tz.dataVersion
. It seems that this property is not mentioned in the docs page, but it is quite easy to get it looking at library code on github.
// Get momentjs version
console.log(moment.version);
// Get moment timezone version
console.log(moment.tz.version);
// Get data used
console.log(moment.tz.dataVersion);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.33/moment-timezone-with-data-2012-2022.min.js"></script>
This is similar to: How to console.log Moment.js version?.