При использовании этого скрипта или функции вы легко можете изменить формат даты: с
2008-11-15 на 15/11/2008
// calling function
$date = "2008-11-15";
$fdate = formatdae($date);
echo $fdate; // Result: 15/11/2008
function formatdate($mysql_stamp,$type=1)
{
//$type = 1 date + time
//$type = 2 date
//$type = 3 time
// split mysql DATETIME stamp into date and time
if($mysql_stamp==""){
return "";
}
@list($date, $time) = split ('[ ]', $mysql_stamp);
@list($year, $month, $day) = split ('[-]', $date);
if( isset($time) && $time != "" )
{
list($hour, $minute, $second) = split ('[:]', $time);
if($hour>=12)
{
$ext = "PM";
$hour = $hour - 12;
}
else
{
$ext = "AM";
}
$time = " ".$hour.":".$minute." ".$ext;
}
else
{
$hour="";
$minute= "" ;
$ext = "";
$time = "";
}
if($type == 1)
$formatted_stamp = "$day/$month/$year".$time;
elseif($type==2)
{
$formatted_stamp = "$day/$month/$year";
}
elseif($type==3)
$formatted_stamp = $time;
return $formatted_stamp;
}
?>
Комментариев нет:
Отправить комментарий