How can I override the moment.js
var defaultInvalidDate = 'Invalid date';
without changing the moment.js file. Just like my site overrides certain bootstrap css styles with a Site.css, so when bootstrap is updated I dont lose the changes, is there any way to make overrides for momentjs?
Thanks in advance
Just update your current locale used by moment.js
using moment.updateLocale(localeName, config)
moment.updateLocale(moment.locale(), { invalidDate: "Invalid Date Updated" })
Here is the working example:
console.log(moment(new Date("Aa")).format(""));
moment.updateLocale(moment.locale(), { invalidDate: "Invalid Date Updated" })
console.log(moment(new Date("Aa")).format(""));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script>
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