A string representing a date.
Let’s see simple example, where will try to get the the number of milliseconds between January 1, 1970 and July 21, 2020:
<!DOCTYPE html> <html> <body> <script> var d = Date.parse("July 21, 2020"); alert(d); </script> </body> </html>
string newDate = moment(currentDate, currentFormatString).format(newFormatString)
moment("21/10/14", "DD/MM/YY").format("MM/DD/YY") would return
Answer: If the input string of date is not correct, it returns NaN (not a number). See below example of it:-
<script> var d = "July 31, 2020 12:30 PM"; var md = Date.parse(d); document.write(md); </script>
Do comment if you have any doubts and suggestions on this topic.
Note: The All JS Examples codes are tested on the Safari browser (Version 12.0.2) and Chrome.
OS: macOS 10.14 Mojave
Code: HTML 5 Version
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.