Home > Article > Web Front-end > How to Parse a Date String in dd.mm.yyyy Format in JavaScript?
In JavaScript, parsing a date string in the format dd.mm.yyyy is a simple process that involves splitting the string into its component parts and creating a Date object.
To achieve this, the following steps should be taken:
Example Code:
<code class="javascript">var strDate = "03.09.1979"; var dateParts = strDate.split("."); var date = new Date(dateParts[2], (dateParts[1] - 1), dateParts[0]);</code>
This code splits the date string "03.09.1979" into ["03", "09", "1979"] and creates a Date object with the corresponding values. The resulting date variable will represent the date September 3, 1979.
The above is the detailed content of How to Parse a Date String in dd.mm.yyyy Format in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!