vusan vusan - 1 year ago 126
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
, etc.

Answer Source

You can simply do this:

let gmt = date['toGMTString']();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download