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: "YYYY-MM-DDTHH:mm:ssZ"
_i: "2015-12-20T12:00:00+02:00"
_isAMomentObject: true
_isUTC: false
_locale: r
_pf: Object
_tzm: 120
How to fetch by right way _tzm
? (suppose its offset in minutes)
Thanks,
Definition and Usage. getTimezoneOffset() returns the difference between UTC time and local time. getTimezoneOffset() returns the difference in minutes. For example, if your time zone is GMT+2, -120 will be returned.
For example, if you parse the string '2020/01/02' and then call the moment#tz() method, you're telling moment to parse the string in the locale time, and then convert the date to a given IANA timezone. // '20200101 21:00 PST' moment('2020/01/02', 'YYYY/MM/DD'). tz('America/Los_Angeles'). format('YYYYMMDD HH:mm z');
What is a "zone offset"? A zone offset is the difference in hours and minutes between a particular time zone and UTC. In ISO 8601, the particular zone offset can be indicated in a date or time value. The zone offset can be Z for UTC or it can be a value "+" or "-" from UTC.
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
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