时间日期字段格式化处理
@access protected
@param  mixed $format    日期格式
@param  mixed $time      时间日期表达式
@param  bool  $timestamp 是否进行时间戳转换
@return mixed
170565
protected function formatDateTime($format, $time = 'now', $timestamp = false)
    {
        if (empty($time)) {
            return;
        }

        if (false === $format) {
            return $time;
        } elseif (false !== strpos($format, '\\')) {
            return new $format($time);
        }

        if ($timestamp) {
            $dateTime = new DateTime();
            $dateTime->setTimestamp($time);
        } else {
            $dateTime = new DateTime($time);
        }

        return $dateTime->format($format);
    }
287948
public static function formatTimestamp($timestamp)
    {
        $rfc3339 = '/^(\d{4})\-?(\d{2})\-?(\d{2})((T|t)(\d{2})\:?(\d{2})' .
                   '\:?(\d{2})(\.\d{1,})?((Z|z)|([\+\-])(\d{2})\:?(\d{2})))?$/';

        if (ctype_digit((string)$timestamp)) {
            return gmdate('Y-m-d\TH:i:sP', $timestamp);
        } elseif (preg_match($rfc3339, $timestamp) > 0) {
            // timestamp is already properly formatted
            return $timestamp;
        } else {
            $ts = strtotime($timestamp);
            if ($ts === false) {
                require_once 'Zend/Gdata/App/InvalidArgumentException.php';
                throw new Zend_Gdata_App_InvalidArgumentException("Invalid timestamp: $timestamp.");
            }
            return date('Y-m-d\TH:i:s', $ts);
        }
    }
692419
public static function createFromFormat($format, $time, $object = NULL)
    {
        $date = $object ? \DateTime::createFromFormat($format, $time, $object)
            : \DateTime::createFromFormat($format, $time);

        return $date !== false ?
            new self($date->format('Y-m-d H:i:s'), $date->getTimezone())
            : false;
    }
1205965
public function format_local($format) {
        // Configure the timezone to account for timezone and/or daylight savings time
        $timezone = new DateTimeZone(date_default_timezone_get());
        $this->setTimezone($timezone);

        $timestamp = $this->getTimestamp();
        return strftime($format, $timestamp);
    }
643305
public static function formatExcelTime($time, $format = '')
    {
        $time = \PHPExcel_Shared_Date::ExcelToPHP($time);
        if ($format) {
            $time = date($format, $time);
        }
        return $time;
    }
534309
public function getDate($format = null)
    {
        $format = empty($format) ? $this->format : $format;

        return strftime($format, $this->ts);
    }
60205
public static function format($date = false, $format = 'Y-m-d H:i:s') {

        if($date) {

            $DateTime = new DateTime($date);
            return $DateTime->format($format);
        }

        return false;
    }
1129527
public function date($field, $format)
    {
        $fieldValue = $this->get($field);

        try {

            $date = new \DateTime($fieldValue);

            return $fieldValue === $date->format($format);
        } catch (\Exception $exception) {
            return $this->error($field, __FUNCTION__);
        }
    }
743180
public function format($format, $value)
    {
        switch ($format) {
            case 'date-time':
                return $this->formatDateTime($value);
            case 'date-time-http':
                return $this->formatDateTimeHttp($value);
            case 'date':
                return $this->formatDate($value);
            case 'time':
                return $this->formatTime($value);
            case 'timestamp':
                return $this->formatTimestamp($value);
            case 'boolean-string':
                return $this->formatBooleanAsString($value);
            default:
                return $value;
        }
    }
526020
public static function format($format, $value)
    {
        switch ($format) {
            case 'date-time':
                return self::formatDateTime($value);
            case 'date-time-http':
                return self::formatDateTimeHttp($value);
            case 'date':
                return self::formatDate($value);
            case 'time':
                return self::formatTime($value);
            case 'timestamp':
                return self::formatTimestamp($value);
            case 'boolean-string':
                return self::formatBooleanAsString($value);
            default:
                return $value;
        }
    }
491836
public function getCreatedTime($format = "")
    {
        $time = $this->created_time;
        if (!empty($format)) {
            $timestamp = strtotime($time);
            $time      = date($format, $timestamp);
        }

        return $time;
    }
56260
public static function formatTime($timestamp = null, $style = 'short')
    {
        $property = $style . 'Time';
        return self::date(self::getLocale()->$property, $timestamp);
    }
705473
public function convertTimestampUnixToSoap($timestamp = null) {
        if (is_null($timestamp)) {
            return strftime(self::DATETIME_FORMAT);
        }
        /**
         * @todo: timezone erachter?
         */
        return strftime(self::DATETIME_FORMAT, $timestamp);
    }
519882
public function convertTime($timestamp)
    {
        $ts = new BigNumber($timestamp, 20);
        $ts->subtract('122192928000000000');
        $ts->divide('10000000.0');
        $ts->round();

        return $ts->getValue();
    }
905167
public function getDateTimeFormat(string $format='Y-m-d H:i:s')
    {
        $this->setDateTimeZone()->setDateTime();

        return $this->dateTime->format($format);
    }
669736
public static function getTimeAgo($timestamp = 1, $type = self::SECOND, $time = null)
    {
        if (empty($time)) {
            $time = time();
        }
        switch ($type) {
            case self::HOUR:
                $result = $time - $timestamp * 60 * 60;
                break;
            case self::MINUTE:
                $result = $time - $timestamp * 60;
                break;
            case self::SECOND:
                $result = $time - $timestamp;
                break;
            case self::YEAR:
                $result = strtotime('-' . $timestamp . ' year', $time);
                break;
            case self::MONTH:
                $result = strtotime('-' . $timestamp . ' month', $time);
                break;
            case self::DAY:
                $result = strtotime('-' . $timestamp . ' day', $time);
                break;
            case self::WEEK:
                $result = strtotime('-' . ($timestamp * 7) . ' day', $time);
                break;
            default:
                $result = $time - $timestamp;
        }
        
        return $result;
    }
437191
public function format($format = '%d/%m/%Y')
    {
        if ($this->time == null) {
            return false;
        }
        
        return strftime($format, $this->time);
    }