Date

24 entries

cal_days_in_month Function Days in a month under a given calendar (calendar extension): CAL_GREGORIAN applies the Gregorian leap rule — divisible by 4 but not 100, or divisible by 400, gives February 29; 2024-02=29 vs 2023-02=28 is the canonical leap-year teaching sample, with 2000/1900 completing the century rules. checkdate Function Validates a Gregorian date. date Function Formats a timestamp into a date string according to a given format. date_create Function Creates a DateTime object (the functional twin of new DateTime; returns false instead of throwing on parse failure). date_create_from_format Function Parses a date string against an explicit format (the functional twin of DateTime::createFromFormat), in contrast to strtotime's free-form parsing — format letters match positionally, overflowing dates are normalized with warnings, and hard errors return false. date_create_immutable / date_create_immutable_from_format Function Immutable date objects (DateTimeImmutable): modify returns a new instance and the original never changes — versus the mutable DateTime; java.time/datetime/time.Time share the philosophy across languages, with JS Date as the mutable exception that must clone to protect itself. date_default_timezone_set Function Sets the default timezone used by all date functions in the script. date_diff Function Computes the difference between two dates, returning a DateInterval. DateTime::modify Function Modifies a date with natural-language relative modifiers ('+1 day', 'next Thursday', '-2 months') — the only mainstream date object with this built in; its month-end overflow semantics differ sharply from the explicit arithmetic of other languages. date_parse Function Leniently parses a date string into a field array (no format needed); failure still returns an array - an odd interface that reports via error_count/errors, contrasted with date_create_from_format's strict-format route. date_parse_from_format Function Parses a date with an explicit format into a field array (with error_count/errors locating character positions) — contrasted with date_create_from_format (returns an object) and date_parse (free-form parsing); strptime/DateTimeFormatter are the language counterparts. date_sun_info Function Returns sunrise/sunset/transit and twilight boundaries as a timestamp array for given coordinates and date (astronomically fixed); it replaces the 8.1-deprecated date_sunrise/date_sunset; polar edges fill with bool. DateTime::getTimestamp Function Converts between a DateTime object and Unix epoch seconds: getTimestamp reads the epoch (date_timestamp_get is its functional twin) and setTimestamp writes it back; contrasted with the seconds-vs-milliseconds API families of other languages. date_timezone_set / date_timezone_get Function Zone-object read/write: date_timezone_set switches a DateTime instance's zone (the instant never moves; only the representation view changes) and date_timezone_get reads it back; contrast with date_default_timezone_set's process-wide default — object-level settings never pollute the global. DateInterval Function A date-interval/duration object: produced by DateTime::diff for the difference between two dates, or constructed manually from an ISO 8601 duration string (e.g. P2D, PT2H30M). DatePeriod Function A date-range iterator: walks a series of dates given a start, an interval and an exclusive end, usable directly in foreach. DateTime Function The object-oriented date-time class (since PHP 5.2): a unified entry point for parsing, formatting, relative modification and interval math, sharing the same engine as the functional date()/strtotime(). getdate / gmdate Function A pairing of the structured date array and always-UTC formatting: getdate returns every field at once (seconds/minutes/hours/mday/wday/mon/year/yday/weekday/month, in local-time semantics), while gmdate formats in UTC regardless of the default timezone (date() follows the default timezone instead). hrtime Function High-resolution monotonic timing: hrtime() returns a [seconds, nanoseconds] array and hrtime(true) a plain nanosecond integer. A monotonic clock only advances - NTP adjustments and DST touch the wall clock only, so use this for timing code and microtime for timestamps. microtime Function Returns the current Unix timestamp (a 'microsec sec' string by default, a float in seconds when passed true). mktime Function Builds a Unix timestamp from year, month, day, hour, minute, and second. strtotime Function Parses a date/time string into a Unix timestamp. time Function Returns the current Unix timestamp in seconds. timezone_identifiers_list Function Returns every IANA timezone identifier the environment can pick from (procedural alias of DateTimeZone::listIdentifiers), filterable by DateTimeZone::ALL/AFRICA/AMERICA/… groups or PER_COUNTRY plus a country code; pairs with date_timezone_set_get's "set a zone" side — list first, then set.