Skip to content
Advertisement

How do I get the current date in JavaScript?

How do I get the current date in JavaScript?

Advertisement

Answer

Use new Date() to generate a new Date object containing the current date and time.

JavaScript

This will give you today’s date in the format of mm/dd/yyyy.

Simply change today = mm +'/'+ dd +'/'+ yyyy; to whatever format you wish.

Advertisement