Posted By

bradless on 04/09/10


Tagged

date iso convert


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

dantreacy
eval
joacoleo
beertigger
ironcrema


convert date to YYYY-MM-DD with PHP


 / Published in: PHP
 

This will convert dates from MM-DD-YYYY to YYYY-MM-DD (iso format)

  1. <?
  2. function convertDate($date) {
  3. $date = preg_replace('/\D/','/',$date);
  4. return date('Y-m-d',strtotime($date));
  5. }
  6.  
  7. print convertDate('11/05/1996'); //prints 1996-11-05
  8. ?>

Report this snippet  

You need to login to post a comment.