Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save date 'without' time in JavaScript

Tags:

javascript

At the moment I save my date like this: ISODate("2014-11-17T16:19:16.224Z"), but I want this result: ISODate("2014-11-16T23:00:00Z"). How can I do this?

like image 542
user3475602 Avatar asked Apr 20 '26 10:04

user3475602


1 Answers

An easier alternative is to use Date.setHours() - in single call you can set what you need - from hours to milliseconds. If you just want to get rid of the time.

var date = new Date();
date.setHours(0,0,0,0);
console.log ( date );
like image 92
Bakudan Avatar answered Apr 22 '26 23:04

Bakudan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!