I have recently added moment-timezone
to my project. Now that I've started using it, I notice I have replaced nearly all my
import * as moment from "moment"
with
import * as moment from "moment-timezone"
I don't see any reason to keep moment
around. Is there any limitation I should be aware of before removing it?
Moment-timezone is a separate npm module from moment, but moment-timezone depends on moment under the hood. So you can install moment-timezone by itself, or both moment and moment-timezone. Once you install moment-timezone, you can require() it in and use it like you would use moment.
The moment.tz constructor takes all the same arguments as the moment constructor, but uses the last argument as a time zone identifier. while tz() is to convert a moment object to a given timezone.
This format is deprecated and will be removed in future.
Remove moment
as a separate package in your package.json and reference moment-timezone
whenever you need an instance of the moment object. In fact, if you don't and you're referencing both packages separately, you'll be loading two largely identical versions of moment.
The documentation referenced by @RobG in his comment is correct, it's just that the moment-timezone
package itself loads moment
as a dependency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With