Why does moment-timezone fail when I use it in ES6 javascript file?
import moment from 'moment';
// import timezone from 'moment-timezone';
const formatTime = ({timestamp}) => {
const formattedDT = moment.tz(timestamp, 'America/Los_Angeles').format('YYYY-MM-DD HH:mm ZZ');
return formattedDT;
};
UPD for 2018 (ES6/React), this works when using npm version of moment-tz
import moment from 'moment-timezone';
moment.tz(moment.tz.guess()).zoneAbbr();
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