Date class

Class date is designed for working with date and time. Possible variants of using it include: calendars, various checks based on dates, etc.

Values may range:
from 01/01/1970 to 01/01/2038.
from 00/00/0000 to 12/31/9999.   [3.4.4]

Do not forget that we have different gaps and overlaps: many countries have so-called Daylight Saving Time, when clock is set ahead (in spring) or back (in autumn) one hour.
For example, in Moscow, there cannot be "02:00, 31 March 2002," while "02:00, 27 October 2002" can be twice.

Numeric value of object of class
date equals to the number of days from EPOCH (00:00:00, 1 January 1970, UTC) to the date specified in the object. This feature is useful when you want to get a relative date, e.g.:

# checking if the file was updated more than a week ago
^if($last_update > $now-7){

The number of days can be fractional, e.g. a day and half is equal to

The class usually operates local date and time. Still, you can get date and time in arbitrary time zone (see

To communicate between computers that are in different time zones it is convinient to exchange values of date/time which do not depend on timezone-UNIX format, which is number of seconds passed since EPOCH, is very convinient here.

Unix and ISO 8601 formats can be used in JavaScript and several other scripting languages that work in browser.

Parser fully supports work with UNIX date format.

Copyright © 1997–2021 Art. Lebedev Studio | Last updated: 29.12.2016