Issue
So I'm getting Data from a C# Rest-Server. One value of the array is of the type Date. When I want to calculate with it for example:
let difference = date1.getTime() - date2.getTime();
I get the following error:
date1.getTime is not a function
I guess the error is, that Date of Java is not the same as Date of Typescript.
Is there a way to convert a value of type Date (Java) to type Date (TypeScript)?
Or I'm I wrong and the error is caused by something else?
Solution
You need to convert the date to Date Object inorder to apply its method.
let difference = new Date(date1).getTime() - new Date(date2).getTime();
Answered By - void
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.