Is there any JavaScript library that takes Java's SimpleDateFormat
pattern and parses a date/time string into a Date
object?
For example, given "2010-12-20"
and "yyyy-MM-dd"
, the function would parse "2010-12-20"
and return a JavaScript Date
.
I noticed that jQuery UI's Date Picker can format and parse a date string, but it doesn't work with a time string.
Thanks.
Is there any JavaScript library that takes Java's SimpleDateFormat
pattern and parses a date/time string into a Date
object?
For example, given "2010-12-20"
and "yyyy-MM-dd"
, the function would parse "2010-12-20"
and return a JavaScript Date
.
I noticed that jQuery UI's Date Picker can format and parse a date string, but it doesn't work with a time string.
Thanks.
Share Improve this question edited Jan 23, 2011 at 0:00 Tom Tucker asked Jan 22, 2011 at 20:44 Tom TuckerTom Tucker 11.9k23 gold badges95 silver badges132 bronze badges 04 Answers
Reset to default 1This might be what you want: http://www.timdown.co.uk/code/simpledateformat.php
I would try the Datejs library: http://www.datejs./
I guess you are not the only looking for it. See this thread that has similar content. In the end, the author had to role his/her own but there are some good suggestions in there that might be of benefit.
Google's GWT project has a class to do this. http://google-web-toolkit.googlecode./svn/javadoc/1.5//google/gwt/i18n/client/DateTimeFormat.html Probably no small job to get that into a standalone javascript, though.