0

I have a very basic question to ask but I can't find it in Google and Stack Overflow too.

How to get current time with format example: 2018-01-22T11:48:39.396000Z in JavaScript?

halfer
  • 19,824
  • 17
  • 99
  • 186
KitKit
  • 8,549
  • 12
  • 56
  • 82
  • 1
    Possible duplicate of [Current time formatting with Javascript](https://stackoverflow.com/questions/14638018/current-time-formatting-with-javascript) – Obsidian Age Mar 02 '18 at 03:44

2 Answers2

1

Is this what you mean?

new Date().toISOString() // "2018-03-02T03:46:26.814Z"

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString

wintermute
  • 110
  • 5
1

You may try this.

 var d = new Date();
 var n = d.toLocaleString([], { hour12: true });
Charles
  • 52
  • 7