1 /** 2 * phpexcel 对读出来的5位数时间进行转换 3 * @param [type] $date [description] 4 * @param boolean $time [description] 5 * @return [type] [description] 6 */ 7 function excelTime($date, $time = false) { 8 if(function_exists(‘GregorianToJD‘)){ 9 if (is_numeric( $date )) { 10 $jd = GregorianToJD( 1, 1, 1970 ); 11 $gregorian = JDToGregorian( $jd + intval ( $date ) - 25569 ); 12 $date = explode( ‘/‘, $gregorian ); 13 $date_str = str_pad( $date [2], 4, ‘0‘, STR_PAD_LEFT )."-". str_pad( $date [0], 2, ‘0‘, STR_PAD_LEFT )."-". str_pad( $date [1], 2, ‘0‘, STR_PAD_LEFT ). ($time ? " 00:00:00" : ‘‘); 14 return $date_str; 15 } 16 }else{ 17 $date=$date>25568?$date+1:25569; 18 /*There was a bug if Converting date before 1-1-1970 (tstamp 0)*/ 19 $ofs=(70 * 365 + 17+2) * 86400; 20 $date = date("Y-m-d",($date * 86400) - $ofs).($time ? " 00:00:00" : ‘‘); 21 } 22 return $date; 23 }
原文地址:https://www.cnblogs.com/songkaixin/p/11121946.html
时间: 2024-11-08 11:38:27