芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/shimoda/lib/Service/DateServiceGregorian.php
. */ namespace Xibo\Service; /** * Class DateServiceGregorian * @package Xibo\Service */ class DateServiceGregorian implements DateServiceInterface { use DateServiceTrait; /** * Get a local date * @param int|\Jenssegers\Date\Date $timestamp * @param string $format * @param string $timezone * @return string */ public function getLocalDate($timestamp = NULL, $format = NULL, $timezone = NULL) { if ($format === NULL) $format = $this->getSystemFormat(); if ($timestamp instanceof \Jenssegers\Date\Date) return $timestamp->format($format); if ($timestamp === NULL) $timestamp = time(); return \Jenssegers\Date\Date::createFromTimestamp($timestamp, $timezone)->format($format); } /** * Get Date from String * @param string $string * @param string $format * @return \Jenssegers\Date\Date */ public function parse($string = null, $format = null) { if ($string === null) { $string = $this->getLocalDate(); $format = null; } if ($format === null) $format = $this->getSystemFormat(); return ($format == 'U') ? \Jenssegers\Date\Date::createFromTimestamp($string) : \Jenssegers\Date\Date::createFromFormat($format, $string); } }