xxxxxxxxxx
const date = new Date(); // Get the current date and time
const dateString = date.toString(); // Convert the date object to a string representation
console.log(dateString); // Output: "Sat Oct 30 2021 16:30:00 GMT-0700 (Pacific Daylight Time)"
xxxxxxxxxx
// There are two flavours
const event = new Date(1993, 6, 28, 14, 39, 7);
// The Old Skool Flava
console.log(event.toString());
// expected output: Wed Jul 28 1993 14:39:07 GMT+0200 (CEST)
// (note: your timezone may vary)
// The Hipster way ;)
console.log(event.toDateString());
// expected output: Wed Jul 28 1993
xxxxxxxxxx
const date = new Date(); // create a new Date object, you may also pass a specific date as an argument
const dateString = date.toLocaleString(); // convert the Date object to a string in the user's local time format
console.log(dateString); // output the string representation of the date
xxxxxxxxxx
const date = new Date(); // Create a new date object
const dateString = date.toLocaleString(); // Convert the date object to a string
console.log(dateString); // Output the string representation of the date