Skip to main content

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*

4
  • for HH/MM/SS just use last three variables and this is time will be in your local time but if you want to get the UTC time just use the getUTC methods. Here's the code. Commented May 21, 2011 at 0:52
  • 46
    I used this solution but tweaked it so that minutes and seconds would show up as :03 or :09 instead of :3 or :9, like so: var min = a.getMinutes() < 10 ? '0' + a.getMinutes() : a.getMinutes(); var sec = a.getSeconds() < 10 ? '0' + a.getSeconds() : a.getSeconds(); Commented Aug 8, 2014 at 16:40
  • 5
    Bug: getMonth() returns a month number between 0 and 11, thus a.getMonth() - 1 is wrong. Commented Aug 27, 2014 at 17:41
  • 2
    Don't need a list of month names, javascript has that, even in IE. var month = a.toLocaleDateString(undefined, {month: 'short'}) Commented Jun 29, 2021 at 21:58