Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.setHours(0,0,0,0) with moment.js

What is the easiest equivalent of date.setHours(0,0,0,0) when using moment.js?

Basically, if I need a new Date() moment with hours, minutes, seconds, and milliseconds zeroed out.

like image 822
Nelu Avatar asked Feb 18 '15 19:02

Nelu


People also ask

What is Moment () hour ()?

The moment(). hour() Method is used to get the hours from the current time or to set the hours. Syntax: moment().hour(); or. moment().

What is Moment () in JavaScript?

MomentJS is a JavaScript library which helps is parsing, validating, manipulating and displaying date/time in JavaScript in a very easy way. This chapter will provide an overview of MomentJS and discusses its features in detail. Moment JS allows displaying of date as per localization and in human readable format.

How do I set timezone in moment?

To change the default time zone, use moment. tz. setDefault with a valid time zone.


1 Answers

Start of Time

moment().startOf('day') 
like image 51
Nelu Avatar answered Oct 11 '22 04:10

Nelu