I'm trying to build a little calendar in JavaScript. I have my dates working great in Firefox and Chrome, but in IE the date functions are returning NaN.
Here is the function :
function buildWeek(dateText){ var headerDates=''; var newDate = new Date(dateText); for(var d=0;d<7;d++){ headerDates += '<th>' + newDate + '</th>'; newDate.setDate(newDate.getDate()+1); } jQuery('div#headerDates').html('<table><tr>'+headerDates+'</tr></table>'); }
dateText
is the Monday of the current week which is actually set in php in the format of 'm, d, Y', e.g. "02, 01, 2010"
.
From a mysql datetime/timestamp format:
var dateStr="2011-08-03 09:15:11"; //returned from mysql timestamp/datetime field var a=dateStr.split(" "); var d=a[0].split("-"); var t=a[1].split(":"); var date = new Date(d[0],(d[1]-1),d[2],t[0],t[1],t[2]);
I hope is useful for someone. Works in IE FF Chrome
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With