How Can I use new Date().setHours(0,0,0) in a single line?

Viewed 157

I want to create a new Date in JavaScript without the timestamp. I'm trying to use the setHours method. I noticed a strange behavior, if I create the object and in the same line I use the setHours, the result will be just numbers, but I don't want that, I want just the Date with the hours:minutes:seconds all setted to zero.

** First Case, that's the desired result, but I want to do this in a single line**

const today = new Date()
today.setHours(0,0,0)
console.log(today)

Second Case, I'd like to do something like this, but with the output of the first case.

const today = new Date().setHours(0,0,0)
console.log(today)

0 Answers
Related