-1

How to get the following format 2019-07-06T09:00:00.000Z using momentjs

What I tried to do is:

console.log(moment().format()); // 2019-07-05T12:29:29+03:00`

What I need is instead of +03:00 --> 000Z in dynamic way of course.

Any momentJS format supported the format above or should I do it manually?

Khaled Ramadan
  • 744
  • 1
  • 8
  • 25

2 Answers2

1

You could use the built-in method toISOString()

console.log(new Date().toISOString())
adiga
  • 31,610
  • 8
  • 53
  • 74
0

console.log(moment().utc().format("YYYY-MM-DDTHH:mm:ss.SSS[Z]"));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
shrys
  • 5,635
  • 2
  • 20
  • 32