Datetime
in package
Tags
Table of Contents
Constants
Methods
- __construct() : mixed
- date_to_string() : string
- Convert a mysql date as a readable date.
- days_to_date() : string
- Convert a number of days into readable UE date support only french and english languages for now.
- get_chrono() : string
- Get the chrono list as a string containing the label, relative time and absolute time for each step.
- get_date_part() : string
- Get an item from a date formatted as "YYYY-MM-DD HH:MM:SS" (mysql date format).
- is_after() : bool
- Check if the first date (in string format) is after/superior the second one.
- is_prior() : bool
- Check if the first date (in string format) is prior/inferior the second one.
- milliseconds() : int
- return timestamp in milliscondes
- mins_to_readable() : string
- Convert a number of minutes into readable time for a time inferior to 24 hours.
- mysql_date() : string
- Convert a timestamp as mysql date string
- mysql_to_html_date() : string
- Convert a mysql date string to a date value for an html input date
- mysql_to_html_datetime() : string
- Convert a mysql date string to a date value for an html input datetime
- seconds_to_readable() : string
- Convert a number of seconds into readable time for a time inferior to 24 hours.
- start_chrono() : mixed
- Start a chrono.
- step_chrono() : mixed
- Add a step to the chrono
Constants
day
public
mixed
day
= 86400
hour
public
mixed
hour
= 3600
minute
public
mixed
minute
= 60
second
public
mixed
second
= 1
Methods
__construct()
public
__construct() : mixed
date_to_string()
Convert a mysql date as a readable date.
public
static date_to_string(string $datetime) : string
Parameters
- $datetime : string
-
mysql date
Return values
string —formatted date as "day month year" (e.g. "12 January 2023") (UE format)
days_to_date()
Convert a number of days into readable UE date support only french and english languages for now.
public
static days_to_date(int|float $d[, string $lang = 'fr' ]) : string
Parameters
- $d : int|float
- $lang : string = 'fr'
-
default is 'fr' for French, can be anything else for English
Return values
string —formatted date as "X an(s) Y mois Z jour(s)" (e.g. "2 ans 3 mois 5 jours") in French or "X year(s) Y month(s) Z day(s)" in English
get_chrono()
Get the chrono list as a string containing the label, relative time and absolute time for each step.
public
get_chrono() : string
Return values
stringget_date_part()
Get an item from a date formatted as "YYYY-MM-DD HH:MM:SS" (mysql date format).
public
static get_date_part(string $date, string $info) : string
Parameters
- $date : string
- $info : string
-
The part requested, can be : date year month day time hour minute second
Return values
string —the requested part of the date, or false if the info is not recognized.
is_after()
Check if the first date (in string format) is after/superior the second one.
public
static is_after(string $date1[, string $date2 = false ]) : bool
by default the second date is now.
Parameters
- $date1 : string
-
the first date
- $date2 : string = false
-
the second one , time() by default
Return values
bool —true / false.
is_prior()
Check if the first date (in string format) is prior/inferior the second one.
public
static is_prior(string $date1[, string $date2 = false ]) : bool
by default the second date is now.
Parameters
- $date1 : string
-
the first date
- $date2 : string = false
-
the second one , time() by default
Return values
bool —true / false.
milliseconds()
return timestamp in milliscondes
public
static milliseconds() : int
Return values
int —milliseconds since Unix epoch (0:00:00 January 1,1970 GMT)
mins_to_readable()
Convert a number of minutes into readable time for a time inferior to 24 hours.
public
static mins_to_readable(int $minutes) : string
Parameters
- $minutes : int
Return values
string —formatted time as "HMM" (e.g. "1H30") or "MMmn" (e.g. "90mn")
mysql_date()
Convert a timestamp as mysql date string
public
static mysql_date([string $timestamp = false ]) : string
If no argument passed return the current time
Parameters
- $timestamp : string = false
Return values
string —formatted date Y-m-d H:i:s
mysql_to_html_date()
Convert a mysql date string to a date value for an html input date
public
static mysql_to_html_date([string $mysql_date = '' ]) : string
If no argument passed return empty
Parameters
- $mysql_date : string = ''
Return values
string —formatted date Y-m-d
mysql_to_html_datetime()
Convert a mysql date string to a date value for an html input datetime
public
static mysql_to_html_datetime([string $mysql_date = '' ]) : string
If no argument passed return the current datetime
Parameters
- $mysql_date : string = ''
Return values
string —formatted date Y-m-d\TH:i:s
seconds_to_readable()
Convert a number of seconds into readable time for a time inferior to 24 hours.
public
static seconds_to_readable(int|float $seconds) : string
Parameters
- $seconds : int|float
Return values
string —formatted time as "HH:MM:SS" (e.g. "01:30:45")
start_chrono()
Start a chrono.
public
start_chrono() : mixed
This will reset the chrono list and start measuring time. It will also add a first step with the label 'start'. Chrono is used to measure the execution time of a script or a process.
step_chrono()
Add a step to the chrono
public
step_chrono([string $label = '' ]) : mixed
Parameters
- $label : string = ''
-
the name that will be displayed with the step