How do I go about converting date to a readable format like mm/dd/yy
? The code below is giving me this: /Date(1335412800000)/
<?php echo '<td>'.$r['effdate'].'</td>'; ?> //displaying this now: /Date(1335412800000)/
How do I go about converting date to a readable format like mm/dd/yy
? The code below is giving me this: /Date(1335412800000)/
<?php echo '<td>'.$r['effdate'].'</td>'; ?> //displaying this now: /Date(1335412800000)/
Try:
<?php
$effdate = date('m/j/Y', preg_replace('/[^\d]/','', $r['effdate'])/1000);
echo '<td>'.$effdate.'</td>';
?>
I am removing all the non digits.
preg_replace('/[^\d]/','', $r['effdate'])
Dividing it by 1000 as epoch times in JavaScript is x 1000.
/1000
Then I return the formatted date.
date('m/j/Y', ...