0

Is there a simple, established way to allow free-form date entry on a web page and parse the input text to get a Date value? We have a new requirement to go from using a date picker to allowing free-form date entry. So the user could theoretically enter any of the following:

12/7/41 12-7-1941 Dec 7, 1941 

And we would have to attempt to parse it and make a date out of it.

I have attempted to find something online but the closest is this JQuery widget which doesn't do the free-form thing. There's also DateJS but it looks unfinished and development stopped in 2008. I'm just wondering if there's anything else out there.

1 Answer 1

2

MomentJS has what you are looking for. It's a robust library with almost all your time and/or date needs handled. MomentJS Parsing: http://momentjs.com/docs/#/parsing/

Sign up to request clarification or add additional context in comments.

2 Comments

Warning: Browser support for parsing strings is inconsistent. Because there is no specification on which formats should be supported, what works in some browsers will not work in other browsers. - momentjs.com/docs/#/parsing/string | Bottom line: use String + Formats
Thank you, this looks great.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.