Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

How do I get the current date in JavaScript?

How do I get the current date in JavaScript?

Answer*

Draft saved
Draft discarded
Cancel
3
  • 1
    Thank you! I knew date had to have a string method, I don't know why everyone is parsing out days and months and years and concatenating.. Even if you wanted dashes: Date().toISOString().split('T')[0].replaceAll('/','-') Commented Mar 17, 2021 at 16:55
  • Yeah, maybe they had something else in mind. Commented Mar 18, 2021 at 3:08
  • 1
    Thank you, I was looking for what's needed to set value in an input date, and this is it – it should be the most common use case! Commented Dec 9, 2022 at 14:29

lang-js

AltStyle によって変換されたページ (->オリジナル) /