How To Get Timezone Offset From Moment Object?
I have moment Object defined as: var moment = require('moment'); moment('2015-12-20T12:00:00+02:00'); When I print it, I get: _d: Sun Dec 20 2015 12:00:00 GMT+0200 (EET) _f: 'YYY
Solution 1:
Just access the property like you would in any object
var result = moment('2015-12-20T12:00:00+02:00');
document.body.innerHTML = result._tzm;
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.1/moment.min.js"></script>
Another option would be to parse the date and get the zone
moment.parseZone('2015-12-20T12:00:00+02:00').utcOffset(); // 120
// or
moment().utcOffset('2015-12-20T12:00:00+02:00')._offset; // 120
Post a Comment for "How To Get Timezone Offset From Moment Object?"