kindy said:
var d = new Date('2009/01/31');
d.setMonth(d.getMonth() + 1);
then,
d will be '2009/03/03'.
Because there is no 2009-02-31 CE. The last day of 2009-02 CE is defined to
be 2009-02-29 CE. The first day of 2009-03 CE is defined to be 2009-03-01
CE. Add the two extra days and you'll get 2009-03-03 CE.
the problem is What is 'one month'?
Exactly. ISTM, time and the calendar, as humble attempts to bring
understanding into the rather odd (in contrast to even) numbers than
humankind has observed in the rotation of its home planet, the revolution
around its primary, and the reflection and shadow created by the primary's
light on the planet's twin (for those who don't know yet: the Moon, or
Luna), along with its relation to neighboring stars, is probably the most
complex and most contradicting algorithm humankind has ever conceived.
Take only the "western" hemisphere and business world for an example: the
business year is divided into 360 days (instead of 365.26~), 52 (or 50)
weeks, 12 months, 4 weeks a month but 30 or 20 work days a month (depending
on the context), but 5 to 7 work days a week (depending on the context), 24
(or 8 to 10; instead of 23.93~) hours a day, 60 minutes an hour, 60 seconds
a minute, 1000 milliseconds a second, and so forth. And then we also have
leap years and even leap seconds (there was one shortly ago), and time
zones, and atomic time etc. pp. It is rather amazing that nobody loses
their mind when thinking about it.
Please don't. And trim your quotes.
<
http://jibbering.com/faq/#posting>
PointedEars