src/Date/DateUtil.php
public function getTimeStamp($date = null, $replaceInsertTags = true, $timezone = null)
    {
        if (null === $date) {
            return 0;
        }

        if ($date instanceof \DateTime) {
            $timezone ? $date->setTimezone(new \DateTimeZone($timezone)) : null;

            return $date->getTimestamp();
        }

        if (true === $replaceInsertTags) {
            $date = Controller::replaceInsertTags($date, false);
        }

        if (is_numeric($date)) {
            $dateTime = new \DateTime(null, $timezone ? new \DateTimeZone($timezone) : null);
            $dateTime->setTimestamp($date);

            return $dateTime->getTimestamp();
        }

        if (false !== ($dateTime = strtotime($date))) {
            $dateTime = new \DateTime($date, $timezone ? new \DateTimeZone($timezone) : null);

            return $dateTime->getTimestamp();
        }

        return 0;
    }
public function getTimeStamp($date = null, $replaceInsertTags = true, $timezone = null)
    {
        if (null === $date) {
            return 0;
        }

        if ($date instanceof \DateTime) {
            $timezone ? $date->setTimezone(new \DateTimeZone($timezone)) : null;

            return $date->getTimestamp();
        }

        if (true === $replaceInsertTags) {
            $date = Controller::replaceInsertTags($date, false);
        }

        if (is_numeric($date)) {
            $dateTime = new \DateTime(null, $timezone ? new \DateTimeZone($timezone) : null);
            $dateTime->setTimestamp($date);

            return $dateTime->getTimestamp();
        }

        if (false !== ($dateTime = strtotime($date))) {
            $dateTime = new \DateTime($date, $timezone ? new \DateTimeZone($timezone) : null);

            return $dateTime->getTimestamp();
        }

        return 0;
    }
public function getTimeStamp ( $ date = null , $ replaceInsertTags = true , $ timezone = null ) { if ( null === $ date ) { return 0 ; } if ( $ date instanceof \ DateTime ) { $ timezone ? $ date -> setTimezone ( new \ DateTimeZone ( $ timezone ) ) : null ; return $ date -> getTimestamp ( ) ; } if ( true === $ replaceInsertTags ) { $ date = Controller :: replaceInsertTags ( $ date , false ) ; } if ( is_numeric ( $ date ) ) { $ dateTime = new \ DateTime ( null , $ timezone ? new \ DateTimeZone ( $ timezone ) : null ) ; $ dateTime -> setTimestamp ( $ date ) ; return $ dateTime -> getTimestamp ( ) ; } if ( false !== ( $ dateTime = strtotime ( $ date ) ) ) { $ dateTime = new \ DateTime ( $ date , $ timezone ? new \ DateTimeZone ( $ timezone ) : null ) ; return $ dateTime -> getTimestamp ( ) ; } return 0 ; }
Get the timestamp based on input date, no matter input is timestamp or string date.

@param string|int|\DateTime|null $date              The input date/timestamp/insertTag
@param bool                      $replaceInsertTags Disable/enable {{date::}} insertTag support
@param string|null               $timezone          A valid timezone from DateTimeZone::ALL, if provided the timezone offset will be added to the timestamp

@throws \Exception Throws error in case of an error when creating new DateTime instances

@return int The integer timestamp presentation of the input date with added timezone offset
Get the timestamp based on input date no matter input is timestamp or string date .