freshbooks-php-sdk

Util
in package

FreshBooks data utils.

Table of Contents

Constants

DATE_FORMAT  : mixed = 'Y-m-d'
ACCOUNTING_FORMAT  : mixed = 'Y-m-d H:i:s'
ACCOUNTING_TIMEZONE  : mixed = 'US/Eastern'
PROJECT_FORMAT  : mixed = 'Y-m-d\TH:i:s\Z'
PROJECT_FORMAT_NO_DESIGNATOR  : mixed = 'Y-m-d\TH:i:s'

Methods

convertContent()  : void
Helper function to convert content from DataModel objects or arrays of DataModel objects.
getAccountingDateTime()  : DateTimeImmutable
Get a datetime zoned to UTC from an accounting endpoint date string.
getDate()  : DateTime
getDateTimeFromTimestamp()  : DateTimeImmutable
Get a datetime zoned to UTC from a Unix timestamp.
getProjectDateTimeFromISO()  : DateTimeImmutable
Get a datetime zoned to UTC from an ISO date string. Eg. "2020-09-13T03:10:13Z"
getProjectDateTimeFromNaiveUTC()  : DateTimeImmutable
Get a datetime zoned to UTC from an project-like endpoint date string.

Constants

DATE_FORMAT

public mixed DATE_FORMAT = 'Y-m-d'

ACCOUNTING_FORMAT

private mixed ACCOUNTING_FORMAT = 'Y-m-d H:i:s'

ACCOUNTING_TIMEZONE

private mixed ACCOUNTING_TIMEZONE = 'US/Eastern'

PROJECT_FORMAT

private mixed PROJECT_FORMAT = 'Y-m-d\TH:i:s\Z'

PROJECT_FORMAT_NO_DESIGNATOR

private mixed PROJECT_FORMAT_NO_DESIGNATOR = 'Y-m-d\TH:i:s'

Methods

convertContent()

Helper function to convert content from DataModel objects or arrays of DataModel objects.

public static convertContent(array<string|int, mixed> &$data, string $key, mixed $value) : void
Parameters
$data : array<string|int, mixed>

The data array to modify.

$key : string

The key in the data array to set.

$value : mixed

The value to convert, can be a DataModel, an array of DataModel, or any other type.

getAccountingDateTime()

Get a datetime zoned to UTC from an accounting endpoint date string.

public static getAccountingDateTime(string|mixed $value[, bool $isUtc = false ]) : DateTimeImmutable

The accounting service stores almost all dates in the US/Eastern timezone.

Parameters
$value : string|mixed

An accounting datetime string. eg. 2021-01-08 20:39:52

$isUtc : bool = false

Whether the input value is in UTC or in the accounting timezone.

Return values
DateTimeImmutable

getDate()

public static getDate(string|mixed $value) : DateTime
Parameters
$value : string|mixed
Return values
DateTime

getDateTimeFromTimestamp()

Get a datetime zoned to UTC from a Unix timestamp.

public static getDateTimeFromTimestamp(int $value) : DateTimeImmutable
Parameters
$value : int

A Unix timestamp.

Return values
DateTimeImmutable

getProjectDateTimeFromISO()

Get a datetime zoned to UTC from an ISO date string. Eg. "2020-09-13T03:10:13Z"

public static getProjectDateTimeFromISO(string|mixed $value) : DateTimeImmutable
Parameters
$value : string|mixed

A project datetime string. eg. "2020-09-13T03:10:13Z"

Return values
DateTimeImmutable

getProjectDateTimeFromNaiveUTC()

Get a datetime zoned to UTC from an project-like endpoint date string.

public static getProjectDateTimeFromNaiveUTC(string|mixed $value) : DateTimeImmutable

The project services store their dates in UTC, but depending on the resource do not indicate that in the response. Eg. "2020-09-13T03:10:13" rather than "2020-09-13T03:10:13Z".

Parameters
$value : string|mixed

A project datetime string. eg. 2020-09-13T03:10:13

Return values
DateTimeImmutable
On this page

Search results