I want to change my below 3 lines to just 1 line.
const date = todayDate(); //console-log: 2023-11-4
const timesasaddastamp = Date.parse(date);
const businessDayDate = new Date(timesasaddastamp); // console-log: Sat Nov 04 2023
How to shorten this?
I tried doing:
const businessDayDate = new Date.parse(date);
2
Answers
If you want today in form of Sat Nov 04 2023, you can simply write this:
Else, you can write like this:
You can achieve the same result in one line by chaining the operations. Here’s how you can do it in one line:
This code will create a Date object for the current date and time and set the time to midnight (00:00:00:000) in one line.