开发者

Days since 1900

I'm using data from Excel2007开发者_运维知识库 as parsed by PHPExcel, and dates come out as days since 1900.

How can I convert to string of YYYY-MM-DD (or anything similar)?


Something like this, should do the trick:

PHPExcel_Style_NumberFormat::toFormattedString($cell->getCalculatedValue(), 'YYYY-MM-DD');


Or use

$phpDate = PHPExcel_Shared_Date::ExcelToPHP($cell->getCalculatedValue());

to convert an Excel/PHPExcel date to a PHP date/timestamp, and then use standard PHP date() function for formatting


purely php

 $datetime1 = new DateTime('1900-01-01');
 $datetime2 = new DateTime(); // today
 $interval = $datetime1->diff($datetime2);
 $days=$interval->format('%a');
 $days+=2; // add boundary days
 echo $days;  // this is the number excel will use
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜