Reputation: 1
So i did this with help cause i am not experienced in jquery
var fullDate = new Date(data[0].date);
var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) : '0' + (fullDate.getMonth()+1);
var currentDate = fullDate.getDate() + "-" + twoDigitMonth + "-" + fullDate.getFullYear();
"<td class='col-md-4'>"+currentDate+"</td>"+
to format the date i work with and in localhost worked great ,but at the server give me NaN errors everything else in the code works great also if i refresh my php code works great too any suggestions ?
Upvotes: 0
Views: 79
Reputation: 1587
The problem can be in:
new Date("data[0].date");
In this case, you are passing the string data[0].date
to the Date()
function, which probably return NaN, because data[0].date
is not valid Date format.
Try to edit your Date()
input to:
new Date(data[0].date);
In the code above, you will post the value of data[0].date
to a Date function, instead of string.
Upvotes: 3