- MomentJS - Home
- MomentJS - Overview
- MomentJS - Environment Setup
- MomentJS - Introduction
- MomentJS - Parsing Date And Time
- MomentJS - Date Validation
- MomentJS - Getter/Setter
- Manipulate Date And Time
- Formatting Date And Time
- MomentJS - Date Queries
- MomentJS - Internationalization
- MomentJS - Customization
- MomentJS - Durations
- MomentJS - Utilities
- MomentJS - Plugins
- MomentJS - Examples
MomentJS - Get
This method gets the year, month, date, hour, minute, second, and millisecond.
Syntax
moment().get('year');
moment().get('month');
moment().get('date');
moment().get('hour');
moment().get('minute');
moment().get('second');
moment().get('millisecond');
Example
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');
Output
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 |
momentjs_getter_setter.htm
Advertisements