Moment new date

You're looking for a way to get the current date and time in JavaScript!

You can use the Date() object to achieve this. Here's an example:

const now = new Date();
console.log(now);

This will output the current date and time in the format YYYY-MM-DDTHH:mm:ss.sssZ.

If you want to format the date and time in a specific way, you can use the toLocaleString() method or create a custom format using template literals. For example:

const now = new Date();
const formattedDate = `${now.toLocaleDateString()} ${now.toLocaleTimeString()}`;
console.log(formattedDate);

This will output the current date and time in the format YYYY-MM-DD, HH:mm:ss.

Alternatively, you can use the moment library, which provides a more flexible and powerful way to work with dates and times. Here's an example:

const moment = require('moment');
const now = moment();
console.log(now.format('YYYY-MM-DDTHH:mm:ss.sssZ'));

This will output the current date and time in the same format as before.

Note that the moment library is not part of the standard JavaScript library, so you'll need to include it in your project if you want to use it.