I’ve inherited a project for a company I’m working for. Their dates are recorded in the following format:
March 18th, 2011 would be listed as “18 Mar 2011”.
April 31st, 2010 would be listed as “31 Apr 2010”.
How would I use Javascript to add one day to a date formatted in the above manner, then reconvert it back into the same format?
I want to create a function that adds one day to “18 Mar 2011” and returns “19 Mar 2011”. Or adds 1 day to “30 Jun 2011” and returns “1 Jul 2011”.
Can anyone help me out?
First of all there is no 31st of April 😉
To the actual issue, the date object can understand the current format when passed as an argument..
demo at http://jsfiddle.net/gaby/jGwYY/1/
The same extraction using (the better supported)
sliceinstead ofsubstrDemo at http://jsfiddle.net/jGwYY/259/