Mr.Easy Answers McFly Mr.Easy Answers McFly - 1 year ago 85
TypeScript Question

Object.estimated (Kinda of Date object) not being processed to Date() type

I'm receiving this Object.estimated from query to a MongoDB:

Object {estimated: Mon Aug 03 2015 02:00:00 GMT-0500 (COT)}

Then I try to make a Date with it:

new Date(referenceToEstimated)

But I get error:
Invalid Date

I'm using angular2 with typescript by the way, I also tried using datePipe from angular2 and it still gives me error.

I need to make estimated object a Date type object

Answer Source

The Date constructor doesn't know what to do with your arbitrary object.

You can try new Date(referencedToEstimated.estimated) instead.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download