Kind of time (yyyymmddThhmmZ)

182 Views Asked by At

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.

2

There are 2 best solutions below

0
Ulises 2010 On BEST ANSWER

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

1
Johan On

That's ISO-8601

The first part is the date in year-month-date order, the second part is the time and the final letter indicates the timezone (here Z for 'Zulu')