HELP! This is making me nuts.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

HELP! This is making me nuts.

binarysearch
I'm developing a rails application that uses keith woods countdown timer. I am trying to convert a mysql datetime to js format so the script can read it correctly.

I copied this code (below) from somewhere to get the job done but it is giving me an error in my firefox error console that says:

timestamp.replace is not a function.

I know this is something really obvious but I'm not a jquery expert and I'm just not seeing it. Any help anyone could provide would be appreciated.

convert timestamp:

$(document).ready(function mysqlTimeStampToDate(timestamp) {
    //function parses mysql datetime string and returns javascript Date object
    //input has to be in this format: 2007-06-05 15:26:02
    var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
    var parts=timestamp.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
    return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
});

call countdown function with converted date:

$(document).ready(function () {
    $('textLayout').countdown({until: mysqlTimeStampToDate("#work_order_hard_completion_datetime"), layout: '{dn}d {hnn}{sep}{mnn}{sep}{snn}'});
});
Loading...