Static methods providing conversions.
package | dstruct_common |
---|
MySQLDateTimeToUTS(string $stamp) : integer
For compatability with Windows languages, a timestamp of 1900-01-01 00:00:00 returns
0 which is 1970-01-01 01:00:00
The function uses PHP's strtotime(), which returns false for timestamps before the start
of the Unix Epoch in 1970 on Windows. If a timestamp is before 1970, the function will return
0 as above.
To ensure consistency in the database, this function should be used in conjunction
with UTSToMySQLDate().
string
Format of 'yyyy-mm-dd hh:mm:ss'
integer
MySQLDateToUTS(string $date) : integer
For compatability with Windows languages, a date of 1900-01-01 returns
0 which is 1970-01-01 01:00:00
The function uses PHP's strtotime(), which returns false for dates before the start
of the Unix Epoch in 1970 on Windows. If a date is before 1970, the function will return
0 as above.
To ensure consistency in the database, this function should be used in conjunction
with UTSToMySQLTimestamp().
string
Format of 'yyyy-mm-dd'
integer
UTSDatePart(integer $uts) : integer
25/08/2008 to 25/08/2008. If one or more of the UTS vars is a timestamp, this won't work if they are not converted to a 'day' timestamp
integer
UTS timestamp
integer
UTS timestampUTSToMySQLDate(integer $uts, boolean $olddate) : string
If $uts = false, returns '1900-01-01' or 1970-01-01. This is to maintain compatability with databases which have to be usable with Windows programming languages which error when confronted with 0000-00-00 dates.
integer
boolean
Return 1900 rather than 1970 if true.
string
Format 'yyyy-mm-dd hh:mm:ss'UTSToMySQLDateTime(integer $uts, boolean $olddate) : string
For MySQL Timestamp fields, you can just insert the UTS without conversion.
integer
UTC Timestamp
boolean
Return 1900 rather than 1970 dates when $uts evaluates to false
string
Format 'yyyy-mm-dd hh:mm:ss'UTSToMySQLTime(integer $uts) : string
integer
string
Time in format 'nn:nn:nn'UserDateToMySQL(string $userdate) : string
string
in format 'dd/mm/yyyy'
string
in format 'yyyy-mm-dd'UserDateToUTS(string $date) : integer
The date must be valid.
string
Format 'dd/mm/yyyy'
integer
UserTimestampToUTS(string $timestamp) : integer
The timestamp must be valid.
string
Format 'dd/mm/yyyy hh:mm:ss'
integer
numericToSortCode(string $numeric) : string
Remember to store your numeric characters as a string rather than integer so that leading zeros are preserved
see | \Convert::sortCodeToNumeric() |
---|
string
expects format nnnnnn
string
in format nn-nn-nnsortCodeToNumeric(string $code) : string
see | \Convert::numericToSortCode() |
---|
string
in format nn-nn-nn
\DStructGeneralException |
---|
string
in format nnnnnn