public function createExcelDate(\DateTime $date)
    {
        $day = clone $date;
        $endDate = $day->setTime(0, 0, 0);
        $startDate = new \DateTime('1970-01-01 00:00:00');
        $diff = $endDate->diff($startDate)->format('%a');

        if ($endDate < $startDate) {
            $daysBetween = 25569 - $diff;
        } else {
            $daysBetween = 25569 + $diff;
        }

        $seconds = $date->getTimestamp() - $endDate->getTimestamp();

        return (float)$daysBetween + ($seconds / 86400);
    }
public function createExcelDate(\DateTime $date)
    {
        $day = clone $date;
        $endDate = $day->setTime(0, 0, 0);
        $startDate = new \DateTime('1970-01-01 00:00:00');
        $diff = $endDate->diff($startDate)->format('%a');

        if ($endDate < $startDate) {
            $daysBetween = 25569 - $diff;
        } else {
            $daysBetween = 25569 + $diff;
        }

        $seconds = $date->getTimestamp() - $endDate->getTimestamp();

        return (float)$daysBetween + ($seconds / 86400);
    }
public function createExcelDate ( \ DateTime $ date ) { $ day = clone $ date ; $ endDate = $ day -> setTime ( 0 , 0 , 0 ) ; $ startDate = new \ DateTime ( '1970-01-01 00:00:00' ) ; $ diff = $ endDate -> diff ( $ startDate ) -> format ( '%a' ) ; if ( $ endDate < $ startDate ) { $ daysBetween = 25569 - $ diff ; } else { $ daysBetween = 25569 + $ diff ; } $ seconds = $ date -> getTimestamp ( ) - $ endDate -> getTimestamp ( ) ; return ( float ) $ daysBetween + ( $ seconds / 86400 ) ; }
Create Excel date stamp from DateTime

@param \DateTime $date
@return float number of days since 1900-01-00
Create Excel date stamp from DateTime