What is the best way to initialize a JavaScript Date to midnight?

Sixty4Bit :

What is the simplest way to obtain an instance of new Date() but set the time at midnight?

CMS :

The setHours method can take optional minutes, seconds and ms arguments, for example:

var d = new Date();
d.setHours(0,0,0,0);

That will set the time to 00:00:00.000 of your current timezone, if you want to work in UTC time, you can use the setUTCHours method.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

In Javascript, what is the best way to convert a NodeList to an array

What is the best way to parse a time into a Date object from user input in Javascript?

What is the best way to profile javascript execution?

What's the best way to initialize a dict of dicts in Python?

What is the best way to get date and time in Clojure?

What is the best way of using Arrays.asList() to initialize a List

What is the best way to initialize a bean?

What's the best way to initialize Quartz?

What is the best way to initialize a pointer to a char array as mutable?

Best Way to detect midnight and reset data

What is the best way to create an array of objects in Javascript?

What is the best way to initialize the Variable in TensorFlow?

What is the best way to projecting fields of JavaScript object?

What's the best way to inject JavaScript into Puppeteer?

What is the best way to include or initialize jQuery library in Vue project?

What is the best way to pass a method when I initialize an object

Best way to initialize QString

What is the best way to concatenate a multidimensional array in Javascript?

What is the best way to initialize a state in ReactNative with custom values on a Modal?

What is the best way to toggle a click event in javascript?

Best way to initialize class members?

Best way to initialize ArrayList and HashMap?

What is the best way to disable a javascript files on Wordpress?

What is the best way to initialize the following instance in my class?

What is the best way to have date and time input in html (from user) and receive in Javascript?

JavaScript: What is the best way to skip a const

What is the best way to convert date format in DOM

What's the best way in JavaScript to get the day of the week of a date string in any time zone?

What is the best way in Blazor to initialize a page that hits the DB to initialize itself