About PHP reading about Excel issues

Source: Internet
Author: User
Tags php excel
About PHP Reading Excel issues
When you read an Excel file in a PHP Excel class, the value of the date cannot be displayed correctly if you encounter an Excel file with a column that is of the date type. How do I get PHP to automatically determine if the column being read is a date type, and if the date type is converted to a value that can be displayed correctly by the conversion function.

------Solution--------------------
I've done this, give you a function, try it, I found it on the internet before.
PHP Code
Excel date Conversion functions function Exceltime ($days, $time =false) {    if (is_numeric ($days)) {        //based on 1900-1-1        $JD = GREGORIANTOJD (1, 1, 1970);        $gregorian = Jdtogregorian ($jd +intval ($days) -25569);        $myDate = explode ('/', $gregorian);        $MYDATESTR = Str_pad ($myDate [2],4, ' 0 ', str_pad_left)                . " -". Str_pad ($myDate [0],2, ' 0 ', str_pad_left)                ." -". Str_pad ($myDate [1],2, ' 0 ', Str_pad_left)                . ( $time? " 00:00:00 ":");        return $myDateStr;    } ElseIf (Strpos ($days, '. ')! ==0) {        return Str_replace ('. ', '-', $days);    }    return $days;}
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.