Search code examples
javascriptdatemomentjsangular-moment

Kind of time (yyyymmddThhmmZ)


I'm trying to generate links to Google calendar and see this tool:

https://decomaan.github.io/google-calendar-link-generator/

And the links are generated as:

https://www.google.com/calendar/render?action=TEMPLATE&text=Appointment+with+VULKOVICH%2C+BILL&details=a+Description&location=a+Location&dates=20210105T103300Z%2F20210114T103300Z

and as you can see the dates are like:

20210105T103300Z

and I am trying to convert this to my own dates but I don't know which type is this and how to format. I have the dates both, in moment or in date, but don't know how to convert.


Solution

  • Since you're using moment.js: moment().utc().format('YYYYMMDDTHHmmss[Z]'), or without a library new Date().toISOString().replace(/\W/g,'').replace(/\d{3}Z/,'Z'). This is really a duplicate of How to format a JavaScript date.

    Source: comment by RobG Jan 11 at 12:58