class Date

$XF->lib->date->ph_check('DE', mktime(0,0,0,8,2,2006)); returns true or flase if it is a public holiday $XF->lib->date->ph_getCaption();returns the name of the with ph_check asked holiday $XF->lib->date->ph_pregenerateHolidays(2005,2006); pregenerates all Holidays from 2005 to 2006 and saves it in db

Properties

$UTC_TO_LOCAL
$UTC_TO_LOCAL_HOURS
$NOW_LOCAL
$NOW_LOCAL_SQL
$NOW_UTC

Methods

array
evaluateRRule(string $rrule)

No description

array
evaluate_rrule(string $rrule) deprecated

No description

array
extrapolate_date_by_rrule(int|string|DateTime $dtstart, string|array $rrule, array $options = array())

Wrapper for rrule dependency Check https://github.com/rlanvin/php-rrule/wiki/RRule for more details

int
get_age(int $timestamp)

Return age in years for this timestamp

string[]
get_date_range(string $start_date, string $end_date, string $returnFormat = "Y-m-d")

Get Date Range

int
get_day_end(int $timestamp)

No description

int
get_day_start(int $timestamp)

No description

int
get_easter(int $year)

Return Easter TS

int
get_first_day_of_month(int $timestamp)

No description

int
get_first_day_of_week(int $timestamp, string $first_day_of_week = 'monday')

No description

array
get_german_holidays(int $year, string $state = null)

Get German Holidays

int
get_last_day_of_month(int $timestamp)

No description

int
get_last_day_of_week(int $timestamp, string $last_day_of_week = 'sunday')

No description

array
get_month_names(bool $shift_index = false)

No description

array
get_timespan_to_timestamp(string $verbal_timespan)

Pass a timespan id (use get_verbal_timespans()) and returns an array with start and end timestamp

false|int
get_timestamp_from_datestring(string $arg, int $datetype = null, bool $utc = false)

Translates a given time string to the corresponding timestamp

array
get_verbal_timespans()

Returns all available verbal timespans

array
get_weekday_names(bool $shift_index = false, bool $fullTextRepresentation = true)

No description

guess_date_format($date)

Determines the date format on basis of its format

int
local_to_utc($timestamp_local)

Converts a LOCAL timestamp to a UTC timestamp

int
query_timeserver(string $server = 'pool.ntp.org')

Query Time Server

string
seconds_to_hours($seconds, $format = 'H:i')

Converts a time in seconds to its corresponding hour format

set_time_constants()

Set Time Vars

int
sqltime_local_to_timestamp_utc($sqltime, $timestamp_utc = NOW_UTC)

Converts a LOCAL SQL Time Format to a UTC timestamp

int
sqltime_to_seconds($sqltime)

Converts a SQL Time Format to seconds (e.g. '10:00:00' to 606010)

int
sqltime_utc_to_timestamp_utc($sqltime, $timestamp_utc = NOW_UTC)

Converts a UTC SQL Time Format to a UTC timestamp

int
utc_to_local($timestamp_utc)

Converts a UTC timestamp to a LOCAL timestamp

verbose_datediff($to_timestamp, $from_timestamp = NOW_UTC, $force_absolute_return = true, $force_output_days = false)

No description

string
verbose_dayscount(int $numberofdays, bool $force_absolute_return = true)

No description

Details

at line 861
array evaluateRRule(string $rrule)

No description

Parameters

string $rrule

RFC-like syntax, e.g. FREQ=DAILY;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR;BYMONTH=1

Return Value

array

= ( 'DTSTART' => null, 'FREQ' => null, 'UNTIL' => null, 'COUNT' => null, 'INTERVAL' => 1, 'BYSECOND' => null, 'BYMINUTE' => null, 'BYHOUR' => null, 'BYDAY' => null, 'BYMONTHDAY' => null, 'BYYEARDAY' => null, 'BYWEEKNO' => null, 'BYMONTH' => null, 'BYSETPOS' => null, 'WKST' => 'MO' )

at line 884
array evaluate_rrule(string $rrule) deprecated

deprecated use evaluateRRule(), This method uses namings which are misleading and non RFC compliant. Examples: Wrong Name (this function) => Correct Name RFC Frequency => int INTERVAL Interval => string FREQ (YEARLY,MONTHLY,..) RepeatMonths => BYMONTH (3,4 for march, april)

No description

Parameters

string $rrule

iCal Recurrence Rule (see: http://www.kanzaki.com/docs/ical/rrule.html)

Return Value

array

at line 808
array extrapolate_date_by_rrule(int|string|DateTime $dtstart, string|array $rrule, array $options = array())

Wrapper for rrule dependency Check https://github.com/rlanvin/php-rrule/wiki/RRule for more details

Please note that the old version of this function was using different/invalid rrule namings and is now using RFC compliant keys

Parameters

int|string|DateTime $dtstart

The recurrence start date and time. Can be given as a string understandable by PHP's DateTime constructor (for example 2015-07-01 14:46:30) a UNIX Timestamp (as int) or a DateTime object

string|array $rrule

= [ 'DTSTART' => null, 'FREQ' => null, 'UNTIL' => null, 'COUNT' => null, 'INTERVAL' => 1, 'BYSECOND' => null, 'BYMINUTE' => null, 'BYHOUR' => null, 'BYDAY' => null, 'BYMONTHDAY' => null, 'BYYEARDAY' => null, 'BYWEEKNO' => null, 'BYMONTH' => null, 'BYSETPOS' => null, 'WKST' => 'MO' ]

array $options

= ['from'=>'2020-12-23', 'until' => '123445667', 'max_count' => 20}

Return Value

array Unixtimestamps

at line 115
int get_age(int $timestamp)

Return age in years for this timestamp

Parameters

int $timestamp

Return Value

int

Years of Age

at line 1122
string[] get_date_range(string $start_date, string $end_date, string $returnFormat = "Y-m-d")

Get Date Range

Parameters

string $start_date

(MYSQL Format)

string $end_date

(MYSQL Format)

string $returnFormat

Format accepted by date().

Return Value

string[]

Format defaults to Y-m-d

Exceptions

Exception

at line 105
int get_day_end(int $timestamp)

No description

Parameters

int $timestamp Timestamp

Return Value

int Timestamp

at line 96
int get_day_start(int $timestamp)

No description

Parameters

int $timestamp Timestamp

Return Value

int Timestamp

at line 971
int get_easter(int $year)

Return Easter TS

Parameters

int $year

Return Value

int

at line 87
int get_first_day_of_month(int $timestamp)

No description

Parameters

int $timestamp Timestamp

Return Value

int Timestamp

at line 127
int get_first_day_of_week(int $timestamp, string $first_day_of_week = 'monday')

No description

Parameters

int $timestamp Timestamp
string $first_day_of_week

First day of week as int (0= Sunday, 1= Monday) OR string (Sunday, Monday..)

Return Value

int Timestamp

at line 984
array get_german_holidays(int $year, string $state = null)

Get German Holidays

Parameters

int $year
string $state

(2 Letter German STATE identifier), HE = Hessen, RP = Rheinland Pfalz...

Return Value

array

at line 164
int get_last_day_of_month(int $timestamp)

No description

Parameters

int $timestamp Timestamp

Return Value

int Timestamp

at line 145
int get_last_day_of_week(int $timestamp, string $last_day_of_week = 'sunday')

No description

Parameters

int $timestamp Timestamp
string $last_day_of_week

Last day of week as int (0= Sunday, 1= Monday) OR string (Sunday, Monday..)

Return Value

int Timestamp

at line 72
array get_month_names(bool $shift_index = false)

No description

Parameters

bool $shift_index

shift name index +1 to be compatible to date("n")

Return Value

array

at line 211
array get_timespan_to_timestamp(string $verbal_timespan)

Pass a timespan id (use get_verbal_timespans()) and returns an array with start and end timestamp

Parameters

string $verbal_timespan

Timespan ID, e.g. today, last_7_days, 'last_week'

Return Value

array

[start, end]

at line 584
false|int get_timestamp_from_datestring(string $arg, int $datetype = null, bool $utc = false)

Translates a given time string to the corresponding timestamp

Parameters

string $arg TimeString
int $datetype

Type of string, e.g. DATETYPE_TIMESTAMP, DATETYPE_STRING_ISO, DATETYPE_STRING_DE,... if null is passed autodetection is being used

bool $utc

Set to true if you require a UTC timestamp back

Return Value

false|int

at line 192
array get_verbal_timespans()

Returns all available verbal timespans

Return Value

array

at line 56
array get_weekday_names(bool $shift_index = false, bool $fullTextRepresentation = true)

No description

Parameters

bool $shift_index

Shift name index +1 to be compatible to date("N")

bool $fullTextRepresentation

Sunday or Sun ?

Return Value

array

at line 516
guess_date_format($date)

Determines the date format on basis of its format

Parameters

$date

at line 174
int local_to_utc($timestamp_local)

Converts a LOCAL timestamp to a UTC timestamp

Parameters

$timestamp_local

Return Value

int

UTC timestamp

at line 1145
int query_timeserver(string $server = 'pool.ntp.org')

Query Time Server

Parameters

string $server

Return Value

int

Timestamp, -1 on Error

at line 509
string seconds_to_hours($seconds, $format = 'H:i')

Converts a time in seconds to its corresponding hour format

Parameters

$seconds
$format

Return Value

string

Formatted hour format

at line 39
set_time_constants()

Set Time Vars

at line 463
int sqltime_local_to_timestamp_utc($sqltime, $timestamp_utc = NOW_UTC)

Converts a LOCAL SQL Time Format to a UTC timestamp

Parameters

$sqltime
$timestamp_utc

Return Value

int

Timestamp UTC

at line 451
int sqltime_to_seconds($sqltime)

Converts a SQL Time Format to seconds (e.g. '10:00:00' to 606010)

Parameters

$sqltime

Return Value

int Seconds

at line 486
int sqltime_utc_to_timestamp_utc($sqltime, $timestamp_utc = NOW_UTC)

Converts a UTC SQL Time Format to a UTC timestamp

Parameters

$sqltime
$timestamp_utc

Return Value

int

Timestamp UTC

at line 184
int utc_to_local($timestamp_utc)

Converts a UTC timestamp to a LOCAL timestamp

Parameters

$timestamp_utc

Return Value

int

LOCAL timestamp

at line 302
verbose_datediff($to_timestamp, $from_timestamp = NOW_UTC, $force_absolute_return = true, $force_output_days = false)

No description

Parameters

$to_timestamp
$from_timestamp
$force_absolute_return
$force_output_days

at line 249
string verbose_dayscount(int $numberofdays, bool $force_absolute_return = true)

No description

Parameters

int $numberofdays

The number of days

bool $force_absolute_return

If set, we add a "before" if the number of days is negative

Return Value

string

$numberofdays + ("days")/("days)