0

Sorry if I have a very basic question to ask but I can't find it in Google and Stackoverflow too.

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

Please help me. Thanks!

KitKit
  • 6,971
  • 11
  • 44
  • 74
  • 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
  • 100
  • 3
1

You may try this.

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