Tom Tucker
Tom Tucker

Reputation: 11916

Converting Java date string to JavaScript date

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.

Upvotes: 5

Views: 3783

Answers (4)

Rich MacDonald
Rich MacDonald

Reputation: 925

Google's GWT project has a class to do this. http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/i18n/client/DateTimeFormat.html Probably no small job to get that into a standalone javascript, though.

Upvotes: 0

limc
limc

Reputation: 40176

This might be what you want: http://www.timdown.co.uk/code/simpledateformat.php

Upvotes: 1

gbvb
gbvb

Reputation: 886

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.

Upvotes: 0

jmbucknall
jmbucknall

Reputation: 2061

I would try the Datejs library: http://www.datejs.com/

Upvotes: 1

Related Questions