\apex\app\utilsdate

Date Library

Service: apex\services\utils\date

Handles various date functions, such ad adding / subtracting intervals from dates, getting the log date, etc.

This class is available within the services container, meaning its methods can be accessed statically via the service singleton as shown below.

PHP Example

</php

namespace apex;

use apex\app; use apex\services\utils\date;

// Add interval $new_date = date::add_interval('M1');

Summary

Methods
Properties
Constants
get_logdate()
add_interval()
subtract_interval()
last_seen()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$secs_hash
N/A

Properties

$secs_hash

$secs_hash : 

Type

Methods

get_logdate()

get_logdate() 

Get log date

Get date for log files. This ensures the date is formatted to DEFAULT_TIMEZONE, instead of UTC or the authenticated user's timezone.

add_interval()

add_interval(string  $interval, string  $from_date, boolean  $return_datestamp = true) : string

Add interval to date.

Parameters

string $interval

The time interval to add formateed in standard Apex format (eg. M1 = 1 month, I30 = 30 minutes, 6H = 6 hours)

string $from_date

The date to add the interval to, defaults to now(). Can be either time in seconds since epoch, or standard timestamp format (YYYY-MM-DD HH:II:SS)

boolean $return_datestamp

If set to false, returns the seconds from epoch, and otherwise returns timestamp (YYYY-MM-DD HH:II:SS)

Returns

string —

The new date.

subtract_interval()

subtract_interval(string  $interval, string  $from_date, boolean  $return_datestamp = true) : string

Subtract interval from date.

Parameters

string $interval

The time interval to add formateed in standard Apex format (eg. M1 = 1 month, I30 = 30 minutes, 6H = 6 hours)

string $from_date

The date to add the interval to, defaults to now(). Can be either time in seconds since epoch, or standard timestamp format (YYYY-MM-DD HH:II:SS)

boolean $return_datestamp

If set to false, returns the seconds from epoch, and otherwise returns timestamp (YYYY-MM-DD HH:II:SS)

Returns

string —

The new date.

last_seen()

last_seen(integer  $secs) 

Get last seen display time.

Parameters

integer $secs

The number of seconds, epoch UNIX time from the PHP time() stamp.