Excel date conversion using PHP Excel

后端 未结 5 1069
予麋鹿
予麋鹿 2020-11-30 03:53

i am reading date from excel which is in this format 12/5/2012 day/month/year using this code to read . using PHP EXCEL

   PHPExcel_Style_NumberFormat::t         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 04:57

    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 putting 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);
    

提交回复
热议问题