How to remove time from Date?

 

To remove the time from a date, use the getFullYear(), getMonth() and getDate() methods to get the year, month and date of the given date and pass the results to new Date() constructor. that return date object without time.

 

var withTime = new Date();
var witoutTime = new Date(withTime.getFullYear(), withTime.getMonth(), withTime.getDate());

Tags:

Share:

Related posts