string to datetime conversion javascript

后端 未结 2 1768
[愿得一人]
[愿得一人] 2021-01-13 11:34

How do I convert string(09-Apr-2010) in to date time (09 April 2010 00:00:00) using java script? I need to compare the dates for validation.

2条回答
  •  攒了一身酷
    2021-01-13 12:20

    check out Date.parse

    str = "09-Apr-2010"
    date = new Date(Date.parse(str.replace(/-/g, " ")))
    alert(date.toLocaleString())
    

提交回复
热议问题