-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
  • 812
  • 1
  • 10
  • 26

2 Answers2

1

You could use the built-in method toISOString()

console.log(new Date().toISOString())
adiga
  • 34,372
  • 9
  • 61
  • 83
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,860
  • 2
  • 21
  • 36