javascript - Date constructor returns NaN in IE, but works in Firefox and Chrome -
I am trying to create a small calendar in javascript. I have my dates for working in Firefox and Chrome, but the date function is returning to NaN in IE
Here is the function:
Function buildback (date text) { Var headerDates = ''; Var newDate = new date (dateText); For {var d = 0; d '; NewDate.setDate (newDate.getDate () +1); } JQuery ('div # headerDates'). Html ('& lt; Table & gt; & lt; tr & gt;' + headerDates + '& lt; / tr & gt; & lt; / table & gt;';); } date text
is the current week's Monday, which is actually set to php in the format of 'm, d, y', e.g. "02, 01, 2010"
.
The date creator accepts any value. If the argument is the primitive [[value]] number, then the date is equal to that value. If the primitive [[value]] is a string, then the specification only guarantees that the date constructor and parse method are able to parse the result of the date. Prototype. String and date.prototype.tyoic string ()
A reliable method of setting a date is to create one and use the setFullYear
and setTime
methods.
An example of that example appears here:
ECMA-262R3 does not define a date format. Date constructor or date Passing string values to parasys is an implementation-dependent result. This is best left.
Edit: Entry from comp.lang.javascript is a common question: An expanded ISO 8601 local date format
YYYY-MM-DD
Can be parsed with date
with the following: - / ** The purse string is formatted as a YYYY-MM-DD in a date object . * If the supplied string does not match format, then * invalid date (value denied) is returned. * @Palam {string} dateStringInRange format YYYY-MM-DD, in the year * 0000-9999 in the category, inclusive. * Return date (date) represents the object strings. * / Function parseISO8601 (dateStringInRange) {var isoExp = / ^ \ s * (\ d {4}) - (\ d \ d) - (\ d \ d) \ s * $ /, date = new date (nan) , Months, parts = isoExp.exec (dateStringInRange); If (parts) {months = + parts [2]; Date.setFullYear (part [1], month - 1, part [3]); If (month! = Date .getMonth () + 1) {date.setTime (NaN); } } return date; }
Comments
Post a Comment