<?php
//轉西元
function dateTo_ad($in_date)
{
$cyear = substr($in_date, 0, -4);
$year = ((int) $cyear )+1911;
$mon = substr($in_date, -4, 2);
$day = substr($in_date, -2);
$date = date("Y-m-d", mktime (0,0,0,$mon ,$day, date($year)));
return $date;
}
//轉民國,後面參數為分隔符號自訂
function dateTo_c($in_date, $in_txt="")
{
$ch_date = explode("-", $in_date);
$ch_date[0] = $ch_date[0]-1911;
$date = '00.00.00';
if ($in_txt=="")
{
$date = '000000';
if ($ch_date[0] > 0 ) $date = $ch_date[0]."".$ch_date[1]."".$ch_date[2];
}
else
{
if ($ch_date[0] > 0 ) $date = $ch_date[0]."$in_txt".$ch_date[1]."$in_txt".$ch_date[2];
}
return $date;
}
全站熱搜
留言列表