//input format: d/m/yy or yyyy
$date = '24/12/08';
$dtmp = explode("/",$date);
$dadate = mktime(0,0,0,$dtmp[1],$dtmp[0],$dtmp[2]);
echo date('d-m-Y',$dadate);
//outputs 24-12-2008
$date = '24/12/08';
$dtmp = explode("/",$date);
$dadate = mktime(0,0,0,$dtmp[1],$dtmp[0],$dtmp[2]);
echo date('d-m-Y',$dadate);
//outputs 24-12-2008
//input format: yyyy-m-d
$date2 = '2011-04-25';
$dtmp = explode("-",$date2);
$dadate2 = mktime(0,0,0,$dtmp[1],$dtmp[2],$dtmp[0]);
echo date('d/m/Y',$dadate2);
//outputs 25/04/2011
$date2 = '2011-04-25';
$dtmp = explode("-",$date2);
$dadate2 = mktime(0,0,0,$dtmp[1],$dtmp[2],$dtmp[0]);
echo date('d/m/Y',$dadate2);
//outputs 25/04/2011
No comments:
Post a Comment