Format Date Convertation





0
Date Submitted Mon. Feb. 27th, 2006 9:45 PM
Revision 1 of 1
Beginner ahlee4u
Tags "date convert"
Comments 0 comments
Converting system dates into user-friendly dates depending on the scenario in which it's used.

<?
function DateConvertion($vold_date, $layout) {
$vold_date = ereg_replace('[^0-9]', '', $vold_date);

$v_year = substr($vold_date,0,4);
$v_month = substr($vold_date,4,2);
$v_day = substr($vold_date,6,2);
$v_hour = substr($vold_date,8,2);
$v_minute = substr($vold_date,10,2);
$v_second = substr($vold_date,12,2);

$vnew_date = date($layout, mktime($v_hour, $v_minute, $v_second, $v_month, $v_day, $v_year));
return $vnew_date;
}

$todays_date = "2006-02-28 11:35:10";

$date1=DateConvertion($todays_date, "l, jS F Y");
echo"$date1<br>";

$date2=DateConvertion($todays_date, "d/m/Y");
echo"$date2<br>";

$date3=DateConvertion($todays_date, "Y/m/d");
echo"$date3<br>";

$date4=DateConvertion($todays_date, "Y/m/d - g:ia");
echo"$date4<br>";

?>
 

YEOW CHEN LEE

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Syntax Master dannyboy

Votes Down


Syntax Master sundaramkumar