Convert the FULL Excel date serial format to Unix timestamp

前端 未结 4 1403
南笙
南笙 2020-11-29 06:08

I\'ve seen lots of references to converting the \"date\" portion of the Excel serial date format, but everyone seems to skip the \"time\" portion of it.

Here is what

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 06:55

    Please use this formula to change from Excel date to Unix date, then you can use "gmdate" to get the real date in PHP:

    UNIX_DATE = (EXCEL_DATE - 25569) * 86400
    

    and to convert from Unix date to Excel date, use this formula:

    EXCEL_DATE = 25569 + (UNIX_DATE / 86400)
    

    After doing this formula into a variable, you can get the real date in PHP using this example:

    $UNIX_DATE = ($EXCEL_DATE - 25569) * 86400;
    echo gmdate("d-m-Y H:i:s", $UNIX_DATE);
    

    Thanks.

提交回复
热议问题