2 回答

TA貢獻1818條經驗 獲得超8個贊
你可以這樣做:
<?php
$date = "01-08-29";
$dates = DateTime::createFromFormat('m-d-y', $date);
$arr = $dates->format('m-d-Y');
echo $str2 = date('m-d-Y', strtotime('-36500 days', strtotime($arr))); //this will result in 08-26-1929
?>

TA貢獻1804條經驗 獲得超3個贊
附加的代碼將返回 PHP Date 對象,你很高興
<?php
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load("test.xlsx");
$sheet = $spreadsheet->getSheet(0);
$cell = $sheet->getCell('B3');
$dateVal = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($cell->getValue());
?>
返回:
DateTime Object
(
[date] => 1929-08-02 00:00:00.000000
[timezone_type] => 3
[timezone] => UTC
)
- 2 回答
- 0 關注
- 550 瀏覽
添加回答
舉報