多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] * [范例](https://www.php.net/manual/zh/datetime.examples.php) ## [DateTime](https://www.php.net/manual/zh/class.datetime.php)— DateTime 类 * [DateTime::add](https://www.php.net/manual/zh/datetime.add.php)— 给一个 DateTime 对象增加一定量的天,月,年,小时,分钟 以及秒。 * [DateTime::__construct](https://www.php.net/manual/zh/datetime.construct.php)— 返回一个新的 DateTime 对象 * [DateTime::createFromFormat](https://www.php.net/manual/zh/datetime.createfromformat.php)— 根据给定的格式解析日期时间字符串 * [DateTime::createFromImmutable](https://www.php.net/manual/zh/datetime.createfromimmutable.php)— Returns new DateTime object encapsulating the given DateTimeImmutable object * [DateTime::getLastErrors](https://www.php.net/manual/zh/datetime.getlasterrors.php)— 获取警告和错误信息 * [DateTime::modify](https://www.php.net/manual/zh/datetime.modify.php)— 修改日期时间对象的值 * [DateTime::__set_state](https://www.php.net/manual/zh/datetime.set-state.php)— __set_state 魔术方法处理函数 * [DateTime::setDate](https://www.php.net/manual/zh/datetime.setdate.php)— 设置 DateTime 对象的日期 * [DateTime::setISODate](https://www.php.net/manual/zh/datetime.setisodate.php)— 设置 ISO 日期 * [DateTime::setTime](https://www.php.net/manual/zh/datetime.settime.php)— 设置 DateTime 对象的时间 * [DateTime::setTimestamp](https://www.php.net/manual/zh/datetime.settimestamp.php)— 以 Unix 时间戳的方式设置 DateTime 对象 * [DateTime::setTimezone](https://www.php.net/manual/zh/datetime.settimezone.php)— 设置 DateTime 对象的时区 * [DateTime::sub](https://www.php.net/manual/zh/datetime.sub.php)— 对一个 DateTime 对象减去一定量的 日、月、年、小时、分钟和秒。 ## [DateTimeImmutable](https://www.php.net/manual/zh/class.datetimeimmutable.php)— The DateTimeImmutable class * [DateTimeImmutable::add](https://www.php.net/manual/zh/datetimeimmutable.add.php)— Adds an amount of days, months, years, hours, minutes and seconds * [DateTimeImmutable::__construct](https://www.php.net/manual/zh/datetimeimmutable.construct.php)— Returns new DateTimeImmutable object * [DateTimeImmutable::createFromFormat](https://www.php.net/manual/zh/datetimeimmutable.createfromformat.php)— Parses a time string according to a specified format * [DateTimeImmutable::createFromMutable](https://www.php.net/manual/zh/datetimeimmutable.createfrommutable.php)— Returns new DateTimeImmutable object encapsulating the given DateTime object * [DateTimeImmutable::getLastErrors](https://www.php.net/manual/zh/datetimeimmutable.getlasterrors.php)— Returns the warnings and errors * [DateTimeImmutable::modify](https://www.php.net/manual/zh/datetimeimmutable.modify.php)— Creates a new object with modified timestamp * [DateTimeImmutable::__set_state](https://www.php.net/manual/zh/datetimeimmutable.set-state.php)— The __set_state handler * [DateTimeImmutable::setDate](https://www.php.net/manual/zh/datetimeimmutable.setdate.php)— Sets the date * [DateTimeImmutable::setISODate](https://www.php.net/manual/zh/datetimeimmutable.setisodate.php)— Sets the ISO date * [DateTimeImmutable::setTime](https://www.php.net/manual/zh/datetimeimmutable.settime.php)— Sets the time * [DateTimeImmutable::setTimestamp](https://www.php.net/manual/zh/datetimeimmutable.settimestamp.php)— Sets the date and time based on a Unix timestamp * [DateTimeImmutable::setTimezone](https://www.php.net/manual/zh/datetimeimmutable.settimezone.php)— Sets the time zone * [DateTimeImmutable::sub](https://www.php.net/manual/zh/datetimeimmutable.sub.php)— Subtracts an amount of days, months, years, hours, minutes and seconds ## [DateTimeInterface](https://www.php.net/manual/zh/class.datetimeinterface.php)— The DateTimeInterface interface * [DateTime::diff](https://www.php.net/manual/zh/datetime.diff.php)— Returns the difference between two DateTime objects * [DateTime::format](https://www.php.net/manual/zh/datetime.format.php)— Returns date formatted according to given format * [DateTime::getOffset](https://www.php.net/manual/zh/datetime.getoffset.php)— Returns the timezone offset * [DateTime::getTimestamp](https://www.php.net/manual/zh/datetime.gettimestamp.php)— Gets the Unix timestamp * [DateTime::getTimezone](https://www.php.net/manual/zh/datetime.gettimezone.php)— Return time zone relative to given DateTime * [DateTime::__wakeup](https://www.php.net/manual/zh/datetime.wakeup.php)— The __wakeup handler ## [DateTimeZone](https://www.php.net/manual/zh/class.datetimezone.php)— The DateTimeZone class * [DateTimeZone::__construct](https://www.php.net/manual/zh/datetimezone.construct.php)— 创建新的DateTimeZone对象 * [DateTimeZone::getLocation](https://www.php.net/manual/zh/datetimezone.getlocation.php)— 返回与时区相关的定位信息。 * [DateTimeZone::getName](https://www.php.net/manual/zh/datetimezone.getname.php)— 返回时区名称。 * [DateTimeZone::getOffset](https://www.php.net/manual/zh/datetimezone.getoffset.php)— 返回相对于 GMT 的时差。 * [DateTimeZone::getTransitions](https://www.php.net/manual/zh/datetimezone.gettransitions.php)— Returns all transitions for the timezone * [DateTimeZone::listAbbreviations](https://www.php.net/manual/zh/datetimezone.listabbreviations.php)— 返回一个包含 dst (夏令时),时差和时区信息的关联数组。 * [DateTimeZone::listIdentifiers](https://www.php.net/manual/zh/datetimezone.listidentifiers.php)— 返回一个包含了所有时区标示符的索引数组。 ## [DateInterval](https://www.php.net/manual/zh/class.dateinterval.php)— DateInterval 类 * [DateInterval::__construct](https://www.php.net/manual/zh/dateinterval.construct.php)— Creates a new DateInterval object * [DateInterval::createFromDateString](https://www.php.net/manual/zh/dateinterval.createfromdatestring.php)— Sets up a DateInterval from the relative parts of the string * [DateInterval::format](https://www.php.net/manual/zh/dateinterval.format.php)— Formats the interval ## [DatePeriod](https://www.php.net/manual/zh/class.dateperiod.php)— DatePeriod 类 * [DatePeriod::__construct](https://www.php.net/manual/zh/dateperiod.construct.php)— Creates a new DatePeriod object * [DatePeriod::getDateInterval](https://www.php.net/manual/zh/dateperiod.getdateinterval.php)— Gets the interval * [DatePeriod::getEndDate](https://www.php.net/manual/zh/dateperiod.getenddate.php)— Gets the end date * [DatePeriod::getRecurrences](https://www.php.net/manual/zh/dateperiod.getrecurrences.php)— Gets the number of recurrences * [DatePeriod::getStartDate](https://www.php.net/manual/zh/dateperiod.getstartdate.php)— Gets the start date  ## [Supported Date and Time Formats](https://www.php.net/manual/zh/datetime.formats.php) * [Time Formats](https://www.php.net/manual/zh/datetime.formats.time.php) * [Date Formats](https://www.php.net/manual/zh/datetime.formats.date.php) * [Compound Formats](https://www.php.net/manual/zh/datetime.formats.compound.php) * [Relative Formats](https://www.php.net/manual/zh/datetime.formats.relative.php)