<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/refs.calendar.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'book.datetime.php',
    1 => 'Date/Time',
    2 => 'Date and Time',
  ),
  'up' => 
  array (
    0 => 'refs.calendar.php',
    1 => 'Date and Time Related Extensions',
  ),
  'prev' => 
  array (
    0 => 'function.unixtojd.php',
    1 => 'unixtojd',
  ),
  'next' => 
  array (
    0 => 'datetime.setup.php',
    1 => 'Installing/Configuring',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/datetime/book.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/book.datetime.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="book.datetime" class="book">
 
 <h1 class="title">Date and Time</h1>
 

 
 <div id="intro.datetime" class="preface">
  <h1 class="title">Introduction</h1>
  <p class="para">
   The <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> and related classes allow you
   represent date/time information. The objects can be created by passing in a
   string presentation of date/time information, or from the current system&#039;s
   time.
  </p>
  <p class="para">
   A rich set of methods is supplied to modify and format this information
   as well, including handling timezones and DST transitions.
  </p>
  <p class="para">
   The date/time features in PHP implements the ISO 8601 calendar, which is a
   <a href="https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar" class="link external">&raquo;&nbsp;proleptic Gregorian
   calendar</a> which implements the current leap-day rules from before the
   Gregorian calendar was in place, and also includes the year
   <code class="literal">0</code> as the year number in between <code class="literal">-1
   BCE</code> and <code class="literal">1 CE</code>. Leap seconds are not supported.
  </p>
  <p class="para">
   The date and time information is internally stored as a 64-bit number so
   all conceivably useful dates (including negative years) are supported. The
   range is from about 292 billion years in the past to the same in the
   future.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    The timezones referenced in this section can be found in the
    <a href="timezones.php" class="xref">List of Supported Timezones</a>.
   </span>
  </p></blockquote>
 </div>
 

 







 




 







 




 




 




 




 




 





 








 

 






 












 



 



 



 



 



 



 



 



 




<ul class="chunklist chunklist_book"><li><a href="datetime.setup.php">Installing/Configuring</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="datetime.installation.php">Installation</a></li><li><a href="datetime.configuration.php">Runtime Configuration</a></li></ul></li><li><a href="datetime.constants.php">Predefined Constants</a></li><li><a href="datetime.examples.php">Examples</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="datetime.examples-arithmetic.php">Date/Time Arithmetic</a></li></ul></li><li><a href="class.datetime.php">DateTime</a> — The DateTime class<ul class="chunklist chunklist_book chunklist_children"><li><a href="datetime.add.php">DateTime::add</a> — Modifies a DateTime object, with added amount of days, months, years, hours, minutes and seconds</li><li><a href="datetime.construct.php">DateTime::__construct</a> — Returns new DateTime object</li><li><a href="datetime.createfromformat.php">DateTime::createFromFormat</a> — Parses a time string according to a specified format</li><li><a href="datetime.createfromimmutable.php">DateTime::createFromImmutable</a> — Returns new DateTime instance encapsulating the given DateTimeImmutable object</li><li><a href="datetime.createfrominterface.php">DateTime::createFromInterface</a> — Returns new DateTime object encapsulating the given DateTimeInterface object</li><li><a href="datetime.getlasterrors.php">DateTime::getLastErrors</a> — Alias of DateTimeImmutable::getLastErrors</li><li><a href="datetime.modify.php">DateTime::modify</a> — Alters the timestamp</li><li><a href="datetime.set-state.php">DateTime::__set_state</a> — The __set_state handler</li><li><a href="datetime.setdate.php">DateTime::setDate</a> — Sets the date</li><li><a href="datetime.setisodate.php">DateTime::setISODate</a> — Sets the ISO date</li><li><a href="datetime.settime.php">DateTime::setTime</a> — Sets the time</li><li><a href="datetime.settimestamp.php">DateTime::setTimestamp</a> — Sets the date and time based on an Unix timestamp</li><li><a href="datetime.settimezone.php">DateTime::setTimezone</a> — Sets the time zone for the DateTime object</li><li><a href="datetime.sub.php">DateTime::sub</a> — Subtracts an amount of days, months, years, hours, minutes and seconds from
   a DateTime object</li></ul></li><li><a href="class.datetimeimmutable.php">DateTimeImmutable</a> — The DateTimeImmutable class<ul class="chunklist chunklist_book chunklist_children"><li><a href="datetimeimmutable.add.php">DateTimeImmutable::add</a> — Returns a new object, with added amount of days, months, years, hours, minutes and seconds</li><li><a href="datetimeimmutable.construct.php">DateTimeImmutable::__construct</a> — Returns new DateTimeImmutable object</li><li><a href="datetimeimmutable.createfromformat.php">DateTimeImmutable::createFromFormat</a> — Parses a time string according to a specified format</li><li><a href="datetimeimmutable.createfrominterface.php">DateTimeImmutable::createFromInterface</a> — Returns new DateTimeImmutable object encapsulating the given DateTimeInterface object</li><li><a href="datetimeimmutable.createfrommutable.php">DateTimeImmutable::createFromMutable</a> — Returns new DateTimeImmutable instance encapsulating the given DateTime object</li><li><a href="datetimeimmutable.getlasterrors.php">DateTimeImmutable::getLastErrors</a> — Returns the warnings and errors</li><li><a href="datetimeimmutable.modify.php">DateTimeImmutable::modify</a> — Creates a new object with modified timestamp</li><li><a href="datetimeimmutable.set-state.php">DateTimeImmutable::__set_state</a> — The __set_state handler</li><li><a href="datetimeimmutable.setdate.php">DateTimeImmutable::setDate</a> — Sets the date</li><li><a href="datetimeimmutable.setisodate.php">DateTimeImmutable::setISODate</a> — Sets the ISO date</li><li><a href="datetimeimmutable.settime.php">DateTimeImmutable::setTime</a> — Sets the time</li><li><a href="datetimeimmutable.settimestamp.php">DateTimeImmutable::setTimestamp</a> — Sets the date and time based on a Unix timestamp</li><li><a href="datetimeimmutable.settimezone.php">DateTimeImmutable::setTimezone</a> — Sets the time zone</li><li><a href="datetimeimmutable.sub.php">DateTimeImmutable::sub</a> — Subtracts an amount of days, months, years, hours, minutes and seconds</li></ul></li><li><a href="class.datetimeinterface.php">DateTimeInterface</a> — The DateTimeInterface interface<ul class="chunklist chunklist_book chunklist_children"><li><a href="datetime.diff.php">DateTimeInterface::diff</a> — Returns the difference between two DateTime objects</li><li><a href="datetime.format.php">DateTimeInterface::format</a> — Returns date formatted according to given format</li><li><a href="datetime.getoffset.php">DateTimeInterface::getOffset</a> — Returns the timezone offset</li><li><a href="datetime.gettimestamp.php">DateTimeInterface::getTimestamp</a> — Gets the Unix timestamp</li><li><a href="datetime.gettimezone.php">DateTimeInterface::getTimezone</a> — Return time zone relative to given DateTime</li><li><a href="datetime.serialize.php">DateTime::__serialize</a> — Serialize a DateTime</li><li><a href="datetime.unserialize.php">DateTime::__unserialize</a> — Unserialize an Datetime</li><li><a href="datetime.wakeup.php">DateTime::__wakeup</a> — The __wakeup handler</li></ul></li><li><a href="class.datetimezone.php">DateTimeZone</a> — The DateTimeZone class<ul class="chunklist chunklist_book chunklist_children"><li><a href="datetimezone.construct.php">DateTimeZone::__construct</a> — Creates new DateTimeZone object</li><li><a href="datetimezone.getlocation.php">DateTimeZone::getLocation</a> — Returns location information for a timezone</li><li><a href="datetimezone.getname.php">DateTimeZone::getName</a> — Returns the name of the timezone</li><li><a href="datetimezone.getoffset.php">DateTimeZone::getOffset</a> — Returns the timezone offset from GMT</li><li><a href="datetimezone.gettransitions.php">DateTimeZone::getTransitions</a> — Returns all transitions for the timezone</li><li><a href="datetimezone.listabbreviations.php">DateTimeZone::listAbbreviations</a> — Returns associative array containing dst, offset and the timezone name</li><li><a href="datetimezone.listidentifiers.php">DateTimeZone::listIdentifiers</a> — Returns a numerically indexed array containing all defined timezone identifiers</li></ul></li><li><a href="class.dateinterval.php">DateInterval</a> — The DateInterval class<ul class="chunklist chunklist_book chunklist_children"><li><a href="dateinterval.construct.php">DateInterval::__construct</a> — Creates a new DateInterval object</li><li><a href="dateinterval.createfromdatestring.php">DateInterval::createFromDateString</a> — Sets up a DateInterval from the relative parts of the string</li><li><a href="dateinterval.format.php">DateInterval::format</a> — Formats the interval</li></ul></li><li><a href="class.dateperiod.php">DatePeriod</a> — The DatePeriod class<ul class="chunklist chunklist_book chunklist_children"><li><a href="dateperiod.construct.php">DatePeriod::__construct</a> — Creates a new DatePeriod object</li><li><a href="dateperiod.createfromiso8601string.php">DatePeriod::createFromISO8601String</a> — Creates a new DatePeriod object from an ISO8601 string</li><li><a href="dateperiod.getdateinterval.php">DatePeriod::getDateInterval</a> — Gets the interval</li><li><a href="dateperiod.getenddate.php">DatePeriod::getEndDate</a> — Gets the end date</li><li><a href="dateperiod.getrecurrences.php">DatePeriod::getRecurrences</a> — Gets the number of recurrences</li><li><a href="dateperiod.getstartdate.php">DatePeriod::getStartDate</a> — Gets the start date</li></ul></li><li><a href="ref.datetime.php">Date/Time Functions</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="function.checkdate.php">checkdate</a> — Validate a Gregorian date</li><li><a href="function.date.php">date</a> — Format a Unix timestamp</li><li><a href="function.date-add.php">date_add</a> — Alias of DateTime::add</li><li><a href="function.date-create.php">date_create</a> — create a new DateTime object</li><li><a href="function.date-create-from-format.php">date_create_from_format</a> — Alias of DateTime::createFromFormat</li><li><a href="function.date-create-immutable.php">date_create_immutable</a> — create a new DateTimeImmutable object</li><li><a href="function.date-create-immutable-from-format.php">date_create_immutable_from_format</a> — Alias of DateTimeImmutable::createFromFormat</li><li><a href="function.date-date-set.php">date_date_set</a> — Alias of DateTime::setDate</li><li><a href="function.date-default-timezone-get.php">date_default_timezone_get</a> — Gets the default timezone used by all date/time functions in a script</li><li><a href="function.date-default-timezone-set.php">date_default_timezone_set</a> — Sets the default timezone used by all date/time functions in a script</li><li><a href="function.date-diff.php">date_diff</a> — Alias of DateTime::diff</li><li><a href="function.date-format.php">date_format</a> — Alias of DateTime::format</li><li><a href="function.date-get-last-errors.php">date_get_last_errors</a> — Alias of DateTimeImmutable::getLastErrors</li><li><a href="function.date-interval-create-from-date-string.php">date_interval_create_from_date_string</a> — Alias of DateInterval::createFromDateString</li><li><a href="function.date-interval-format.php">date_interval_format</a> — Alias of DateInterval::format</li><li><a href="function.date-isodate-set.php">date_isodate_set</a> — Alias of DateTime::setISODate</li><li><a href="function.date-modify.php">date_modify</a> — Alias of DateTime::modify</li><li><a href="function.date-offset-get.php">date_offset_get</a> — Alias of DateTime::getOffset</li><li><a href="function.date-parse.php">date_parse</a> — Returns associative array with detailed info about given date/time</li><li><a href="function.date-parse-from-format.php">date_parse_from_format</a> — Get info about given date formatted according to the specified format</li><li><a href="function.date-sub.php">date_sub</a> — Alias of DateTime::sub</li><li><a href="function.date-sun-info.php">date_sun_info</a> — Returns an array with information about sunset/sunrise and twilight begin/end</li><li><a href="function.date-sunrise.php">date_sunrise</a> — Returns time of sunrise for a given day and location</li><li><a href="function.date-sunset.php">date_sunset</a> — Returns time of sunset for a given day and location</li><li><a href="function.date-time-set.php">date_time_set</a> — Alias of DateTime::setTime</li><li><a href="function.date-timestamp-get.php">date_timestamp_get</a> — Alias of DateTime::getTimestamp</li><li><a href="function.date-timestamp-set.php">date_timestamp_set</a> — Alias of DateTime::setTimestamp</li><li><a href="function.date-timezone-get.php">date_timezone_get</a> — Alias of DateTime::getTimezone</li><li><a href="function.date-timezone-set.php">date_timezone_set</a> — Alias of DateTime::setTimezone</li><li><a href="function.getdate.php">getdate</a> — Get date/time information</li><li><a href="function.gettimeofday.php">gettimeofday</a> — Get current time</li><li><a href="function.gmdate.php">gmdate</a> — Format a GMT/UTC date/time</li><li><a href="function.gmmktime.php">gmmktime</a> — Get Unix timestamp for a GMT date</li><li><a href="function.gmstrftime.php">gmstrftime</a> — Format a GMT/UTC time/date according to locale settings</li><li><a href="function.idate.php">idate</a> — Format a local time/date part as integer</li><li><a href="function.localtime.php">localtime</a> — Get the local time</li><li><a href="function.microtime.php">microtime</a> — Return current Unix timestamp with microseconds</li><li><a href="function.mktime.php">mktime</a> — Get Unix timestamp for a date</li><li><a href="function.strftime.php">strftime</a> — Format a local time/date according to locale settings</li><li><a href="function.strptime.php">strptime</a> — Parse a time/date generated with strftime</li><li><a href="function.strtotime.php">strtotime</a> — Parse about any English textual datetime description into a Unix timestamp</li><li><a href="function.time.php">time</a> — Return current Unix timestamp</li><li><a href="function.timezone-abbreviations-list.php">timezone_abbreviations_list</a> — Alias of DateTimeZone::listAbbreviations</li><li><a href="function.timezone-identifiers-list.php">timezone_identifiers_list</a> — Alias of DateTimeZone::listIdentifiers</li><li><a href="function.timezone-location-get.php">timezone_location_get</a> — Alias of DateTimeZone::getLocation</li><li><a href="function.timezone-name-from-abbr.php">timezone_name_from_abbr</a> — Returns a timezone name by guessing from abbreviation and UTC offset</li><li><a href="function.timezone-name-get.php">timezone_name_get</a> — Alias of DateTimeZone::getName</li><li><a href="function.timezone-offset-get.php">timezone_offset_get</a> — Alias of DateTimeZone::getOffset</li><li><a href="function.timezone-open.php">timezone_open</a> — Alias of DateTimeZone::__construct</li><li><a href="function.timezone-transitions-get.php">timezone_transitions_get</a> — Alias of DateTimeZone::getTransitions</li><li><a href="function.timezone-version-get.php">timezone_version_get</a> — Gets the version of the timezonedb</li></ul></li><li><a href="datetime.error.tree.php">Date/Time Errors and Exceptions</a></li><li><a href="datetime.formats.php">Supported Date and Time Formats</a></li><li><a href="timezones.php">List of Supported Timezones</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="timezones.africa.php">Africa</a></li><li><a href="timezones.america.php">America</a></li><li><a href="timezones.antarctica.php">Antarctica</a></li><li><a href="timezones.arctic.php">Arctic</a></li><li><a href="timezones.asia.php">Asia</a></li><li><a href="timezones.atlantic.php">Atlantic</a></li><li><a href="timezones.australia.php">Australia</a></li><li><a href="timezones.europe.php">Europe</a></li><li><a href="timezones.indian.php">Indian</a></li><li><a href="timezones.pacific.php">Pacific</a></li><li><a href="timezones.others.php">Others</a></li></ul></li><li><a href="class.dateerror.php">DateError</a> — The DateError class</li><li><a href="class.dateobjecterror.php">DateObjectError</a> — The DateObjectError class</li><li><a href="class.daterangeerror.php">DateRangeError</a> — The DateRangeError class</li><li><a href="class.dateexception.php">DateException</a> — The DateException class</li><li><a href="class.dateinvalidoperationexception.php">DateInvalidOperationException</a> — The DateInvalidOperationException class</li><li><a href="class.dateinvalidtimezoneexception.php">DateInvalidTimeZoneException</a> — The DateInvalidTimeZoneException class</li><li><a href="class.datemalformedintervalstringexception.php">DateMalformedIntervalStringException</a> — The DateMalformedIntervalStringException class</li><li><a href="class.datemalformedperiodstringexception.php">DateMalformedPeriodStringException</a> — The DateMalformedPeriodStringException class</li><li><a href="class.datemalformedstringexception.php">DateMalformedStringException</a> — The DateMalformedStringException class</li></ul></div><?php manual_footer($setup); ?>