Parameters: This function takes a parameter of datestring which is taken as the input.
Return Values: It returns an integer value representing the number of millisecond between midnight January 1, 1970, and the date provided. If by any means, the machine can’t recognize the string or the input string is invalid, it will return “NaN” instead of an integer.
If the input string of date is not correct, it return NaN i.e, not a number.
Why 01 Jan 1970 00:00:00 GMT?
It is called the Unix time i.e. the time Unix was invented. Almost all the programming languages, operating systems use this as their reference starting time.
Note: Once we get the millisecond count between two dates, we can easily find the number of hours, days, months, years, etc by simple maths calculation.