Hi Friends đź‘‹,

Welcome to Infinitbility ❤️!

Today, we are going to learn How to convert date to date string format in typescript, here we will use built-in method .toString() to convert date to string date.

First, we will create sample new date() object variable, after then, we will use .toString() method to convert it on string date format.

let’s dive in code…

let date = new Date();
console.log(date); // 2022-04-25T08:21:19.833Z

let strDate: string = date.toString()
console.log(strDate) // 'Mon Apr 25 2022 13:51:13 GMT+0530 (India Standard Time)'

Well, when you run above code, you can able to see date converted in string date format.

For now, let’s check the output.

Output

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

All the best đź‘Ť.