- MomentJS Tutorial
- 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 Useful Resources
- MomentJS - Quick Guide
- MomentJS - Useful Resources
- MomentJS - Discussion
MomentJS - Set
This method will set the unit with the value provided. The unit is the first param and the value as the second. It can also take the unit, value pair in object form.
Syntax
moment().set(String, Int); moment().set(Object(String, Int));
Example
var m = moment().set('year', 2020); var d = moment().set('month', 5); var a = moment().set('date', 28); var k = moment().set({hour:10, minute:25, second:50});
Output
momentjs_getter_setter.htm
Advertisements