I am new to Node Js
I am using Date.now() to get the timestamp of current time
But i wanted the timestamp value of only current date not including the time.
For Example
Now current time is August 9, 2017 8:19:28 PM and the timestamp will be 1502309968000
But I want timestamp of only August 9, 2017 12:00:00 AM and the timestamp will be 1502236800000
How to solve this ?
Asked
Active
Viewed 2,589 times
0

Rudresh
- 75
- 3
- 13
-
The question is confusing! Only date means only `August 9, 2017` – SaidbakR Aug 09 '17 at 20:33
3 Answers
4
Create a date object, and set hours, minutes, seconds and milliseconds to zero
var date = new Date();
date.setHours(0,0,0,0);
var time = date.getTime();
console.log(time);
Note that setHours
accepts minutes, seconds etc. as well.
.setHours(hoursValue[, minutesValue[, secondsValue[, msValue]]])

adeneo
- 312,895
- 29
- 395
- 388