\cge_date_utils

A set of convenience methods to work with dates and times

Summary

Methods
Properties
Constants
str_to_timestamp()
ts_set_time()
ts_set_time_from_str()
is_leapyear()
days_in_month()
date_at()
ts_to_dbformat()
from_locale_str()
to_locale_str()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

str_to_timestamp()

str_to_timestamp(string $str) : int

Convert a string to a timestamp.

An alias for strtotime

Parameters

string $str

The input date/time string

Returns

int —

The unix timestamp

ts_set_time()

ts_set_time(int $timestamp, int $hour, int $minutes) : int

Given a unxix timestamp, an hour and minutes value adjust the unix timestamp accordingly.

Parameters

int $timestamp
int $hour
int $minutes

Returns

int

ts_set_time_from_str()

ts_set_time_from_str(int $timestamp, string $str) : int

Create a unix timestamp from a string.

adjust the unix timestamp accordingly.

Parameters

int $timestamp
string $str

Returns

int

is_leapyear()

is_leapyear(int $year) : bool

Test if the given year (or the current year) is a leapyear

Parameters

int $year

Optional year.

Returns

bool

days_in_month()

days_in_month(int $month, int $year) : int

Return the days in the given month/year

Parameters

int $month

The specified month, if not specified the current month is used.

int $year

The specified year. If not specified, the current year is used.

Returns

int

date_at()

date_at(int $month, int $day, int $year, int $hour, int $minute, int $seconds) : \cge_date

Create a cge_date given specified time values

Parameters

int $month
int $day
int $year
int $hour
int $minute
int $seconds

Returns

\cge_date

ts_to_dbformat()

ts_to_dbformat(int $ts) : string

Convert a timestamp to database format

Parameters

int $ts

Returns

string

from_locale_str()

from_locale_str(string $str) : int

Convert a locale specific date/time string to a unix timestamp

Parameters

string $str

The input string

Returns

int —

The unix timestamp.

to_locale_str()

to_locale_str(int $ts, bool $time_too, string $sep) : string

Convert a unix timestamp to a locale specific format (currently only support US and non US).

Parameters

int $ts

The unix timestamp

bool $time_too

Wether or not to include time in the output string

string $sep

The separator between fields. Default is '/'

Returns

string