Hi,
Could someone please tell me what is wrong with this loop, I am trying to convert a variable to an array:
Where:
howold = ["2004, 5, 26, 13, 23, 0, 0","2004, 5, 26, 13, 23, 0, 0","2004, 5, 26, 13, 23, 0, 0"];
for (j=0; j<4; j++) {
atemp = howold[j];
var temp = [];
var begin = 0;
var firstSpace = atemp.indexOf(",");
var lastSpace = atemp.lastIndexOf(",");
for (var i = 0; i<atemp.length; i++) {
if (end != lastSpace) {
end = atemp.indexOf(",", begin+1);
temp = atemp.substring(begin, end, end-begin);
begin = atemp.indexOf(",", end)+1;
} else {
break;
}
}
temp.push(atemp.substring(lastSpace+1, atemp.length));
my_date = new Date(temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6]);
todate.push(my_date.dateDiff("h", now));
}
What currently happens is the although it picks each array from howold each time, it does not go further split the string to an array after the first time.
Any help is welcome.
Regards,
Sanjay
Could someone please tell me what is wrong with this loop, I am trying to convert a variable to an array:
Where:
howold = ["2004, 5, 26, 13, 23, 0, 0","2004, 5, 26, 13, 23, 0, 0","2004, 5, 26, 13, 23, 0, 0"];
for (j=0; j<4; j++) {
atemp = howold[j];
var temp = [];
var begin = 0;
var firstSpace = atemp.indexOf(",");
var lastSpace = atemp.lastIndexOf(",");
for (var i = 0; i<atemp.length; i++) {
if (end != lastSpace) {
end = atemp.indexOf(",", begin+1);
temp = atemp.substring(begin, end, end-begin);
begin = atemp.indexOf(",", end)+1;
} else {
break;
}
}
temp.push(atemp.substring(lastSpace+1, atemp.length));
my_date = new Date(temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6]);
todate.push(my_date.dateDiff("h", now));
}
What currently happens is the although it picks each array from howold each time, it does not go further split the string to an array after the first time.
Any help is welcome.
Regards,
Sanjay