Hi Friends đź‘‹,

Welcome to Infinitbility ❤️!

Today, I’m going to show you how to convert string to date object in typescript, here we will use new Date() method to convert date string to date.

Let’s start the code.

Suppose, you will get '1968-11-16T00:00:00' this type of string from api and want use as a date then you have to pass this string in date object like this new Date('1968-11-16T00:00:00').

After that you can perform any date operation on thet.

let dateString = '1968-11-16T00:00:00' 
let newDate = new Date(dateString)

Output

TypeScript, convert string to date example
TypeScript, convert string to date example

All the best đź‘Ť.