This method gets the year, month, date, hour, minute, second, and millisecond.
moment().get('year'); moment().get('month'); moment().get('date'); moment().get('hour'); moment().get('minute'); moment().get('second'); moment().get('millisecond');
var m = moment().get('year'); var d = moment().get('month'); var a = moment().get('date'); var k = moment().get('hour'); var o = moment().get('minute'); var s = moment().get('second'); var ms = moment().get('millisecond');
For the get method, the units taken are shown in the table below. Note that the units can be case insensitive or plural. Observe the table shown below −
year or years or y |
month or months or M |
date or dates or D |
hour or hours or H |
Minute or minutes or m |
second or seconds or s |
millisecond or milliseconds or ms |