class CRM_Utils_Time

Date time utilties

Methods

static date
getTime(string $returnFormat = 'YmdHis')

Get the time.

static int
getTimeRaw()

Get the time.

static date
setTime(string $newDateTime, string $returnFormat = 'YmdHis')

Set the given time.

static 
resetTime()

Remove any time overrides.

static bool
isEqual(string $a, string $b, int $threshold)

Approximate time-comparison. $a and $b are considered equal if they are within $threshold seconds of each other.

Details

at line 53
static date getTime(string $returnFormat = 'YmdHis')

Get the time.

Parameters

string $returnFormat Format in which date is to be retrieved.

Return Value

date

at line 63
static int getTimeRaw()

Get the time.

Return Value

int seconds since epoch

at line 77
static date setTime(string $newDateTime, string $returnFormat = 'YmdHis')

Set the given time.

Parameters

string $newDateTime A date formatted with strtotime.
string $returnFormat Format in which date is to be retrieved.

Return Value

date

at line 85
static resetTime()

Remove any time overrides.

at line 101
static bool isEqual(string $a, string $b, int $threshold)

Approximate time-comparison. $a and $b are considered equal if they are within $threshold seconds of each other.

Parameters

string $a Time which can be parsed by strtotime.
string $b Time which can be parsed by strtotime.
int $threshold Maximum allowed difference (in seconds).

Return Value

bool