Hi Friends 👋,
Welcome to Infinitbility ❤️!
This tutorial will help you to convert date to iso format in typescript, here we will use the
toISOString() method to convert date to iso format.
The toISOString() method returns a string in simplified extended ISO format (ISO 8601), which is always 24 or 27 characters long (YYYY-MM-DDTHH:mm:ss.sssZ or ±YYYYYY-MM-DDTHH:mm:ss.sssZ, respectively). The timezone is always zero UTC offset, as denoted by the suffix “Z”.
Let’s start today’s tutorial How to convert date to iso format in typescript?
Before diving into code, let’s see what we are going to do.
- Create a date and store it in a variable.
- check converted date output
1const date = new Date('05 October 2011 14:48 UTC');2console.log(date.toISOString());3// expected output: 2011-10-05T14:48:00.000Z
When you run the above code, you will get an iso date format example output.
For now, let’s check the output.
All the best 👍.
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.