Return to Snippet

Revision: 25801
at April 9, 2010 08:46 by bradless


Updated Code
<?
function convertDate($date) {
	$date = preg_replace('/\D/','/',$date);
	return date('Y-m-d',strtotime($date));
}

print convertDate('11/05/1996'); //prints 1996-11-05
?>

Revision: 25800
at April 9, 2010 08:43 by bradless


Initial Code
<?

function convertDate($date) {
	$date = preg_replace('/\D/','/',$date);
	return date('Y-m-d',strtotime($date));
}

print convertDate('11/05/1996'); //prints 1996-11-05
?>

Initial URL

                                

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

Initial Title
convert date to YYYY-MM-DD with PHP

Initial Tags
date, convert

Initial Language
PHP