User:Jeremy Hutchinson/Javascript Notes

From The CA Plex Wiki

Jump to: navigation, search
  • When constructing a date object from a string year date and month, remember that the month is zeroth based.
  • The parseInt funtion tries to be too clever in trying to work out if you are trying to convert a hexidecimal or octal number depending on whehter the string starts with 0x or 0. This causes problems if your month or day is 08 or 09 as these are not valid octals..., so you have to specify the radix as below:
return new Date(parseInt(strYear,10), parseInt(strMonth,10)-1, parseInt(strDay,10));
Personal tools