I'm looking for a JavaScript library which can parse and format date values and numbers. It should not be too big or complicated just 4 methods would suffice for me: parseDate, formatDate, parseNumber, formatNumber
//dt is a JavaScript date object, str a string containing a date, formatoptions specifies the format
var dt = parseDate(str, formatoptions);
var str = formatDate(dt, formatoptions);
//same applies for parseNumber and formatNumber just replace dt with nr which represents a JavaScript number
I've already asked Mr. Google but there are sooo many libraries and articles out there that it is hard to find something good. Many libs can format a number or date but can't parse them. Or they are not stable (reasonably bug-free).
Any recommendations?
update:
- Sadly serverside processing is not really on option. I know support for date and time manipulation is much better in PHP or ASP
- I included some sample code wha开发者_C百科t I would expect from the parse and format functions
update 2:
I found quite a good library for formatting numbers which is called jquery-numberformatter
I have been using date.js from http://www.datejs.com. The parser in the home page will give you an idea of its capabilities.
These days I would look at MomentJs. Theres plenty of documentation and tests.
精彩评论