I'm trying to use date function on Typescript:
let date = new Date();
let gmt = date.toGMTString();
Now error I got is:
Property 'toGMTString' does not exist on type 'Date'
So how to convert local date to GMT using typescript?
Other methods are working fine like getTime(), getDate(), etc.
toGMTString() is deprecated, that's why it is not included in Date typings. You can use toUTCString() instead.
You can simply do this:
let gmt = date['toGMTString']();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With