Convert string to date in JavaScript

放肆的年华 提交于 2020-05-15 05:13:06

问题


I have a string looking like so:

"2013/1/16"

Is there any way I could quickly convert it into date object in javascript, something like:

convertToDateTime("2013/1/16", "yyyy/MM/dd")

回答1:


It's pretty simple:

var myDate = new Date("2013/1/16");

That should do the trick.
Have a look at the documentation for the Date object



来源:https://stackoverflow.com/questions/14197175/convert-string-to-date-in-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!