tableHTML += "<td class=\"stamp\">"+jsonObject[i]['stamp']+"</td>";
this is currently displaying 2012-05-25 23:08:57how can i change this to a May 25,2012
a commentor noted that it may be better to do this with php, the only time i could do it with php is before entering it to the array. is this possible?
$videos_array = array();
while ($i < $num) {
$current_video = array (
'stamp'=>mysql_result($result,$i,"stamp"));
array_push($videos_array, $current_video);
$i++;
}
echo json_encode($videos_array);
Use a real date library as Dr.Dredel suggests, but if you want an awful hack, there is always
Not to be used in serious code. It relies on the output of
toDateStringwhich is locale dependent. The proper way to do this is to take a date object and just before you are to display it, choose a date format.The built-in date object in JavaScript does not do a good job of this.
You can find examples of its use in the MDN documentation.
ADDENDUM
Okay, I’ve gotten serious and produced an example using datejs. You can find a live working version here.
Basically, put the following in your HTML:
Then in your JavaScript adapt the following code: