I need the current date in following format at 00:00:00 time.
Like say current date is July 22 2021 Then I need that date along with 00:00:00 time.
Expected Output:
Fri 22 july 2022 00:00:00 IST2021
CodePudding user response:
I guess This will work for you
console.log(new Date().toString())
output- Fri Jul 22 2022 17:03:24 GMT 0530 (India Standard Time)
CodePudding user response:
I guess This will work
const d = new Date();
var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var dayName = days[d.getDay()];
const months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
let month = months[d.getMonth()];
const zone = String(String(d).split("(")[1]).split(")")[0].replace(/[^A-Z]/g, '');
const dateTime = dayName " " month " " d.getDate() " " d.getFullYear() " " d.getHours() ":" d.getMinutes() ":" d.getSeconds() " " zone;
console.log(dateTime);
output- Fri July 22 2022 17:12:3 PST