用于excel 导入日期格式 格式化成 年月日形式
- function excelTime($days, $time=false,$str='-'){
- if(!$days)return false;
- if(function_exists("gregoriantojd")){
- if(is_numeric($days)){
- //based on 1900-1-1
- $jd = gregoriantojd(1, 1, 1970);
- $gregorian = jdtogregorian($jd+intval($days)-25569);
- $myDate = explode('/',$gregorian);
- $myDateStr = str_pad($myDate[2],4,'0', STR_PAD_LEFT)
- .$str.str_pad($myDate[0],2,'0', STR_PAD_LEFT)
- .$str.str_pad($myDate[1],2,'0', STR_PAD_LEFT)
- .($time?" 00:00:00":'');
- return $myDateStr;
- }
- }else{
- $date=$days>25568?$days+1:25569;
- $ofs=(70 * 365 + 17+2) * 86400;
- $days = date("Y".$str."m".$str."d",($date * 86400) - $ofs).($time ? " 00:00:00" : "");
- }
- return $days;
- }
复制代码
|