Possible Duplicate:
How to parseInt a string with leading 0
I’m using Google Chrome ver. 21.0.1180.89
I execute:
var a="07:30";
console.log(a.substring(0,2)+" --> "+parseInt(a.substring(0,2)));
the output is right: “07 –> 7” OK
I execute:
var a="08:30";
console.log(a.substring(0,2)+" --> "+parseInt(a.substring(0,2)));
the output is right: “08 –> 0” WRONG
why?
String begins with “0” taken as octal. You have to set radix 10 in
parseInt()Try this,