TIME & DATE
in physics is defined by its measurement: time is what a clock reads.
In classical, non-relativistic physics it is a scalar quantity and, like length, mass, and charge, is usually described as a fundamental quantity.
Time can be combined mathematically with other physical quantities to derive other concepts such as motion, kinetic energy and time-dependent fields.
Timekeeping is a complex of technological and scientific issues, and part of the foundation of recordkeeping.
The unit of time in the
International System of Units, SI, is the
second, (s).
As such, it is defined as the duration of
9 192 631 770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the
cesium-133 atom at a temperature of 0 kelvin.
Although the historical definition of unity was based on this division of Earth's rotation cycle.
As the Earth's rotation varies and is also decreasing slightly, a second leap is added periodically to the watch to keep the clocks synchronized with the Earth's rotation.
Multiples of seconds are usually counted in hours and minutes.
Fractions of a second are usually counted in tenths or hundredths.
In scientific work, small fractions of a second are counted in milliseconds, microseconds, nanoseconds and sometimes smaller units of a second.
Normally, the day is divided using the sexagemal system, and is therefore based on astronomical observation.
A
DATE is a specific time that can be named, for example a particular day a particular month or a particular year.
A
DATE therefore, is the designation of a single, specific day within such a system.
CALENDAR CALENDAR is a system of organizing days for social, religious, commercial or administrative purposes.
This is done by giving names to periods of time, typically days, weeks, months and years.
A
CALENDAR is also a physical record of such a system.
A
CALENDAR can also mean a list of planned events, such as a court
CALENDAR or a partly or fully chronological list of documents, such as a
CALENDAR of wills.
In PHP, when we study the calendar library functions, we deal with the following calendars:
CONSTANT NAME |
VALUES |
CALENDAR NAME |
NO NAME |
-1 |
ALL BELOW |
CAL_GREGORIAN |
0 or NULL |
Gregorian |
CAL_JULIAN |
1 |
Julian |
CAL_JEWISH |
2 |
Jewish |
CAL_FRENCH |
3 |
French Revolutionary |
ed48 |
What you must know about calendars:
Julian calendar
French Republican calendar
Hebrew calendar
Gregorian calendar
CLASSES USED IN THIS TUTORIAL
List of classes used in the exercises proposed by this tutorial.
<?php
DateTimeZone {
/* Constants */
const integer AFRICA = 1 ;
const integer AMERICA = 2 ;
const integer ANTARCTICA = 4 ;
const integer ARCTIC = 8 ;
const integer ASIA = 16 ;
const integer ATLANTIC = 32 ;
const integer AUSTRALIA = 64 ;
const integer EUROPE = 128 ;
const integer INDIAN = 256 ;
const integer PACIFIC = 512 ;
const integer UTC = 1024 ;
const integer ALL = 2047 ;
const integer ALL_WITH_BC = 4095 ;
const integer PER_COUNTRY = 4096 ;
/* Methods */
public __construct ( string $timezone )
public array getLocation ( void )
public string getName ( void )
public int getOffset ( DateTime $datetime )
public array getTransitions ([ int $timestamp_begin [, int $timestamp_end ]] )
public static array listAbbreviations ( void )
public static array listIdentifiers ([ int $what = DateTimeZone::ALL [, string $country = NULL ]] )
}
?>
<?php
DateTime implements DateTimeInterface {
/* Inherited constants */
const string DateTimeInterface::ATOM = "Y-m-d\TH:i:sP" ;
const string DateTimeInterface::COOKIE = "l, d-M-Y H:i:s T" ;
const string DateTimeInterface::ISO8601 = "Y-m-d\TH:i:sO" ;
const string DateTimeInterface::RFC822 = "D, d M y H:i:s O" ;
const string DateTimeInterface::RFC850 = "l, d-M-y H:i:s T" ;
const string DateTimeInterface::RFC1036 = "D, d M y H:i:s O" ;
const string DateTimeInterface::RFC1123 = "D, d M Y H:i:s O" ;
const string DateTimeInterface::RFC7231 = "D, d M Y H:i:s \G\M\T" ;
const string DateTimeInterface::RFC2822 = "D, d M Y H:i:s O" ;
const string DateTimeInterface::RFC3339 = "Y-m-d\TH:i:sP" ;
const string DateTimeInterface::RFC3339_EXTENDED = "Y-m-d\TH:i:s.vP" ;
const string DateTimeInterface::RSS = "D, d M Y H:i:s O" ;
const string DateTimeInterface::W3C = "Y-m-d\TH:i:sP" ;
/* Methods */
public __construct ( string $datetime = "now" , DateTimeZone|null $timezone = null )
public add ( DateInterval $interval ) : DateTime
public static createFromFormat ( string $format , string $datetime , DateTimeZone|null $timezone = null ) : DateTime|false
public static createFromImmutable ( DateTimeImmutable $object ) : DateTime
public static createFromInterface ( DateTimeInterface $object ) : DateTime
public static getLastErrors ( ) : array|false
public modify ( string $modifier ) : DateTime|false
public static __set_state ( array $array ) : DateTime
public setDate ( int $year , int $month , int $day ) : DateTime
public setISODate ( int $year , int $week , int $dayOfWeek = 1 ) : DateTime
public setTime ( int $hour , int $minute , int $second = 0 , int $microsecond = 0 ) : DateTime
public setTimestamp ( int $timestamp ) : DateTime
public setTimezone ( DateTimeZone $timezone ) : DateTime
public sub ( DateInterval $interval ) : DateTime
public diff ( DateTimeInterface $targetObject , bool $absolute = false ) : DateInterval
public format ( string $format ) : string
public getOffset ( ) : int
public getTimestamp ( ) : int
public getTimezone ( ) : DateTimeZone|false
public __wakeup ( ) : void
}
?>
<?php
DateTimeImmutable implements DateTimeInterface {
/* Inherited constants */
const string DateTimeInterface::ATOM = "Y-m-d\TH:i:sP" ;
const string DateTimeInterface::COOKIE = "l, d-M-Y H:i:s T" ;
const string DateTimeInterface::ISO8601 = "Y-m-d\TH:i:sO" ;
const string DateTimeInterface::RFC822 = "D, d M y H:i:s O" ;
const string DateTimeInterface::RFC850 = "l, d-M-y H:i:s T" ;
const string DateTimeInterface::RFC1036 = "D, d M y H:i:s O" ;
const string DateTimeInterface::RFC1123 = "D, d M Y H:i:s O" ;
const string DateTimeInterface::RFC7231 = "D, d M Y H:i:s \G\M\T" ;
const string DateTimeInterface::RFC2822 = "D, d M Y H:i:s O" ;
const string DateTimeInterface::RFC3339 = "Y-m-d\TH:i:sP" ;
const string DateTimeInterface::RFC3339_EXTENDED = "Y-m-d\TH:i:s.vP" ;
const string DateTimeInterface::RSS = "D, d M Y H:i:s O" ;
const string DateTimeInterface::W3C = "Y-m-d\TH:i:sP" ;
/* Methods */
public __construct ( string $datetime = "now" , DateTimeZone|null $timezone = null )
public add ( DateInterval $interval ) : DateTimeImmutable
public static createFromFormat ( string $format , string $datetime , DateTimeZone|null $timezone = null ) : DateTimeImmutable|false
public static createFromInterface ( DateTimeInterface $object ) : DateTimeImmutable
public static createFromMutable ( DateTime $object ) : DateTimeImmutable
public static getLastErrors ( ) : array|false
public modify ( string $modifier ) : DateTimeImmutable|false
public static __set_state ( array $array ) : DateTimeImmutable
public setDate ( int $year , int $month , int $day ) : DateTimeImmutable
public setISODate ( int $year , int $week , int $dayOfWeek = 1 ) : DateTimeImmutable
public setTime ( int $hour , int $minute , int $second = 0 , int $microsecond = 0 ) : DateTimeImmutable
public setTimestamp ( int $timestamp ) : DateTimeImmutable
public setTimezone ( DateTimeZone $timezone ) : DateTimeImmutable
public sub ( DateInterval $interval ) : DateTimeImmutable
public diff ( DateTimeInterface $targetObject , bool $absolute = false ) : DateInterval
public format ( string $format ) : string
public getOffset ( ) : int
public getTimestamp ( ) : int
public getTimezone ( ) : DateTimeZone|false
public __wakeup ( ) : void
}
?>
<?php
DateTimeInterface {
/* Constants */
const string ATOM = "Y-m-d\TH:i:sP" ;
const string COOKIE = "l, d-M-Y H:i:s T" ;
const string ISO8601 = "Y-m-d\TH:i:sO" ;
const string RFC822 = "D, d M y H:i:s O" ;
const string RFC850 = "l, d-M-y H:i:s T" ;
const string RFC1036 = "D, d M y H:i:s O" ;
const string RFC1123 = "D, d M Y H:i:s O" ;
const string RFC7231 = "D, d M Y H:i:s \G\M\T" ;
const string RFC2822 = "D, d M Y H:i:s O" ;
const string RFC3339 = "Y-m-d\TH:i:sP" ;
const string RFC3339_EXTENDED = "Y-m-d\TH:i:s.vP" ;
const string RSS = "D, d M Y H:i:s O" ;
const string W3C = "Y-m-d\TH:i:sP" ;
/* Methods */
public diff ( DateTimeInterface $targetObject , bool $absolute = false ) : DateInterval
public format ( string $format ) : string
public getOffset ( ) : int
public getTimestamp ( ) : int
public getTimezone ( ) : DateTimeZone|false
public __wakeup ( ) : void
}
?>
<?php
Exception implements Throwable {
/* Properties */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Methods */
public __construct ( string $message = "" , int $code = 0 , Throwable $previous = null )
final public getMessage ( ) : string
final public getPrevious ( ) : Throwable|null
final public getCode ( ) : mixed
final public getFile ( ) : string
final public getLine ( ) : int
final public getTrace ( ) : array
final public getTraceAsString ( ) : string
public __toString ( ) : string
final private __clone ( ) : void
}
?>
<?php
Throwable {
/* Methods */
abstract public getMessage ( ) : string
abstract public getCode ( ) : int
abstract public getFile ( ) : string
abstract public getLine ( ) : int
abstract public getTrace ( ) : array
abstract public getTraceAsString ( ) : string
abstract public getPrevious ( ) : Throwable|null
abstract public __toString ( ) : string
}
?>
<?php
DateInterval {
/* Properties */
public int $y ;
public int $m ;
public int $d ;
public int $h ;
public int $i ;
public int $s ;
public float $f ;
public int $invert ;
public mixed $days ;
/* Methods */
public __construct ( string $duration )
public static createFromDateString ( string $datetime ) : DateInterval|false
public format ( string $format ) : string
}
?>
<?php
DatePeriod implements Traversable {
/* Constants */
const int EXCLUDE_START_DATE = 1 ;
/* Properties */
public int $recurrences ;
public bool $include_start_date ;
public DateTimeInterface $start ;
public DateTimeInterface $current ;
public DateTimeInterface $end ;
public DateInterval $interval ;
/* Methods */
public __construct ( DateTimeInterface $start , DateInterval $interval , int $recurrences , int $options = 0 )
public __construct ( DateTimeInterface $start , DateInterval $interval , DateTimeInterface $end , int $options = 0 )
public __construct ( string $isostr , int $options = 0 )
public getDateInterval ( ) : DateInterval
public getEndDate ( ) : DateTimeInterface|null
public getRecurrences ( ) : int|null
public getStartDate ( ) : DateTimeInterface
}
?>