How to get current date?

0123

You can get the current date in JavaScript using the Date object. Here’s a simple example:

const currentDate = new Date();
console.log(currentDate.toISOString().split("T")[0]); // Outputs the date in yyyy-mm-dd format

This code creates a new Date object representing the current date and time, and then formats it to a string in the yyyy-mm-dd format.

0 Comments

no data
Be the first to share your comment!