Skip to content Skip to sidebar Skip to footer

Date() Function In Javascript Giving NAN-NAN-NAN In Firefox And Chrome While Working Fine With IE

I am calculating on date part through java script , but it is giving NAN-NAN-NAN in Firefox and chrome while working fine in IE . My code is below which is i am using. var datedisp

Solution 1:

This?

var date, i, string;

function date_to_string( date ) {
    return ( date.getMonth() + 1 ) + '-' + date.getDate() + '-' + date.getFullYear();
}

date = new Date( '01/27/2012' );

for ( i = 0; i < 14; i += 1 ) {
    date.setDate( date.getDate() + 1 );
    string = date_to_string( date );
    // use string
}

Live demo: http://jsfiddle.net/ekaDg/


Post a Comment for "Date() Function In Javascript Giving NAN-NAN-NAN In Firefox And Chrome While Working Fine With IE"