vusan vusan - 19 days ago 5
TypeScript Question

Property 'toGMTString' does not exist on type 'Date'

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.

Answer

You can simply do this:

let gmt = date['toGMTString']();
Comments