how to print date in javascript without time
function WithoutTime(dateTime) { var date = new Date(dateTime.getTime()); date.setHours(0, 0, 0, 0); return date; }
Here is what the above code is Doing:
1. We’re creating a new Date object, and setting it to the current date and time.
2. We’re setting the hours, minutes, seconds, and milliseconds to 0.
3. We’re returning the new Date object.