How To Convert Date Tnto ISOString And Vice Versa

It’s often necessary to convert Date into a standardized format that can be easily parsed and understood by different systems. One such format is the ISO string format, which uses a standard notation to represent dates and times in a consistent way.

  •  To convert a date object into an ISO string, we can use the toISOString() method that is built into the Date object. This method returns a string that represents the date and time in ISO format.

Let see example:

const date = new Date();
const isoString = date.toISOString();

It represents the current date and time in ISO format.

The format of the string is as follows: YYYY-MM-DDTHH:mm:ss.sssZ


  • YYYY is the four-digit year
  • MM is the two-digit month (with January being 01 and December being 12)
  • DD is two-digit day of the month
  • T is an literal character that separates the date and time
  • HH is two-digit hour in 24-hour format
  • mm is the two-digit minute
  • ss is the two-digit second
  • sss is the three-digit millisecond
  • Z is a literal character that indicates that the time is in UTC
  • To convert a ISOString in to date we have to pass ISOString into date object which will return Date

Let see example:

const isoString = "2023-02-17T12:01:39.094Z"
const date = new Date(isoString)


Also you can show case ISOString into any format you want here is a blog link below is link for same 👇

Hope you find solution to convert date into ISOString

Feel free to reach in comment section if you have any doubt.

Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories