Hello Friends 👋,
Welcome To Infinitbility! ❤️
To get the current date in typescript has the
Date() object it will return every time the current date and time when we use it.
we have to just write
new Date() and it returns the date object where we get a year, month, date, hours, minutes, and seconds.
1let today: object = new Date();2console.log(today); // 2022-02-06T08:05:49.292Z
Now, we know we have the current date but when we want to convert the date in UTC or want to get the UTC date-time we have also followed some other steps.
To get UTC date and time typescript have
new Date().toISOString() it will return currnt UTC date time string.
Hear, ISO full form is
International Organization for Standardization.
1let today: string = new Date().toISOString();2console.log(today) // 2022-02-07T11:42:04.426Z'
Thanks for reading…
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.