![MomentJS Tutorial](/momentjs/images/momentjs-mini-logo.jpg)
- 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 - Start of Time
Start of Time method will set the display to the start of the unit given.
Syntax
moment().startOf(String);
Example using year as the input
var day = moment().startOf('year');
This will display the first day of the year and will set the time, that is hours, minutes, seconds to 00:00:00 as shown below −
![Start](/momentjs/images/start.jpg)
Example using month as the input
var day = moment().startOf('month');
This will display the first day of the month and will set the time, that is hours, minutes and seconds to 00:00:00 as shown below −
![Start Month](/momentjs/images/start_month.jpg)
Example using quarter as the input
var day = moment().startOf('quarter');
This will give the details of the start of the current quarter. Time will be set to 12 am.
Output
![Current Quarter](/momentjs/images/current_quarter.jpg)
If we check the quarter for the month of February using the command shown here, the output will be from 1st of Jan as shown below −
var day = moment().startOf('quarter');
Output
![Start Quarter](/momentjs/images/start_quarter.jpg)
Example using week as the input
var day = moment().startOf('week');
Output
![Start Week](/momentjs/images/start_week.jpg)
momentjs_manipulate_date_and_time.htm
Advertisements