How to Convert Date Format in PHP
<?
$enterd_date = "2010-01-28";
echo "Entered Date = ".$enterd_date."<br />";
echo "Converted Date = ".dateconvert($enterd_date,2);
function dateconvert($date,$func) {
if ($func == 1){
list($day, $month, $year/*if you use this function this order should match your entered date format*/) = split('[-.]', $date);
$date = "$year-$month-$day";
return $date;
}
if ($func == 2){
list($year, $month, $day) = split('[-.]', $date);
$date = "$day-$month-$year";
return $date;
}
}
?>
No comments:
Post a Comment