I have a function that takes a Date object as its paramater. I am not able to figure out how to annotate this.
function diffDate (start: any, end:any) { //.... }
start
and end
as Date objects?
If the variables are of Date object type, we will check whether the getTime() method for the date variable returns a number or not. The getTime() method returns the total number of milliseconds since 1, Jan 1970. If it doesn't return the number, it means the date is not valid.
You can create a Date object using the Date() constructor of java. util. Date constructor as shown in the following example. The object created using this constructor represents the current time.
JavaScript Date objects represent a single moment in time in a platform-independent format. Date objects contain a Number that represents milliseconds since 1 January 1970 UTC.
Thanks loganfsmyth and Nikita for the comments. It works as expected.
function diffDate (start: Date, end: Date) { // ... }
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