Public Method Details |
Bs_Date |
|
public void Bs_Date( )
|
| |
constructor.
|
| Returns |
void |
|
now |
|
public string now( )
|
| |
returns the current datetime in us style.
this function is an alias for this->formatUnixTimestamp('us-1')
|
| Returns |
string current datetime in us style. |
|
formatUnixTimestamp |
|
public string formatUnixTimestamp( [ string $style, string $unixTimestamp ] )
|
| |
returns a unix timestamp formatted as a datetime, eg 982591823 -> 19.02.2001 15:10:23.
this method uses getFormatForStyle().
|
| Parameter |
|
| string |
$style |
= >>'eu-2'<< |
|
how the datetime should be returned. getFormatForStyle(). default is 'eu-2'. |
|
|
| string |
$unixTimestamp |
= >>NULL<< |
|
(a unix timestamp or none. none means 'use the current date/time'.) |
|
| Returns |
string |
|
formatArray |
|
public string formatArray( [ string $style, string $array ] )
|
| |
returns a date-array formatted as a date, time or datetime.
this method uses getFormatForStyle().
|
| Parameter |
|
| string |
$style |
= >>'eu-2'<< |
|
how the datetime should be returned. getFormatForStyle(). default is 'eu-2'. |
|
|
| string |
$array |
= >>NULL<< |
|
(none means 'use the current date/time'.) |
|
| Returns |
string |
|
getFormatForStyle |
|
public string getFormatForStyle( [ string $style ] )
|
| |
takes a style definition and returns the format for it. see below.
possible values for the $style param:'eu-1' -> dd.mm.yyyy hh:mm:ss'eu-2' -> dd.mm.yyyy hh:mm'eu-3' -> dd.mm.yyyy'eu-4' -> hh:mm:ss'eu-5' -> hh:mm'us-1' -> yyyy/mm/dd hh:mm:ss'us-2' -> yyyy/mm/dd hh:mm'us-3' -> yyyy/mm/dd'us-4' -> hh:mm:ss'us-5' -> hh:mm'sql-1' -> yyyy-mm-dd hh:mm:ss'sql-2' -> yyyy-mm-dd hh:mm'sql-3' -> yyyy-mm-dd'sql-4' -> hh:mm:ss'sql-5' -> hh:mm'ts-1' -> yyyymmddhhmmss
|
| Parameter |
|
| string |
$style |
= >>'eu-2'<< |
|
(see above) |
|
| Returns |
string |
|
formatUsDatetime |
|
public string formatUsDatetime( [ string $style, string $usDatetime ] )
|
| |
returns a us datetime formatted as any datetime, eg 1999/08/27 13:39:36 -> 27.08.1999 13:39:36
this method makes use of formatUnixTimestamp(), so watch out for the $style options.
|
| Parameter |
|
| string |
$style |
= >>'eu-2'<< |
|
how the datetime should be returned. see below. default is 'eu-2'. |
|
|
| string |
$usDatetime |
= >>NULL<< |
|
a us datetime or none. none means 'use the current date/time'. |
|
| Returns |
string |
| See Also |
formatUnixTimestamp() |
|
formatEuDatetime |
|
public string formatEuDatetime( [ string $style, string $euDatetime ] )
|
| |
returns a eu datetime formatted as any datetime, eg 27.8.1999 13:39:36 -> 1999/08/27 13:39:36
this method makes use of formatUnixTimestamp(), so watch out for the $style options.
|
| Parameter |
|
| string |
$style |
= >>'eu-2'<< |
|
how the datetime should be returned. see below. default is 'eu-2'. |
|
|
| string |
$euDatetime |
= >>NULL<< |
|
a eu datetime or none. none means 'use the current date/time'. |
|
| Returns |
string |
| See Also |
formatUnixTimestamp() |
|
formatSqlDatetime |
|
public string formatSqlDatetime( [ string $style, string $sqlDatetime ] )
|
| |
returns a sql datetime formatted as any datetime, eg 1999-08-27 13:39:36 -> 27.8.1999 13:39:36
this method makes use of formatUnixTimestamp(), so watch out for the $style options.
|
| Parameter |
|
| string |
$style |
= >>'eu-2'<< |
|
how the datetime should be returned. see below. default is 'eu-2'. |
|
|
| string |
$sqlDatetime |
= >>NULL<< |
|
a sql datetime or none. none means 'use the current date/time'. |
|
| Returns |
string |
| See Also |
formatUnixTimestamp() |
|
formatSqlTimestamp |
|
public string formatSqlTimestamp( [ string $style, string $sqlTimestamp ] )
|
| |
returns a mysql timestamp formatted as a datetime, eg 19990827133936 -> 27.08.1999 13:39:36
this method makes use of formatUnixTimestamp(), so watch out for the $style options.
|
| Parameter |
|
| string |
$style |
= >>'eu-2'<< |
|
how the datetime should be returned. see below. default is 'eu-2'. |
|
|
| string |
$sqlTimestamp |
= >>NULL<< |
|
a sql timestamp or none. none means 'use the current date/time'. |
|
| Returns |
string |
| See Also |
formatUnixTimestamp() |
|
sqlTimestampToUnixTimestamp |
|
public string sqlTimestampToUnixTimestamp( string $sqlTimestamp )
|
| |
converts an sql timestamp into a unix timestamp. eg 20010219151023 -> 982591823
|
| Parameter |
|
|
| Returns |
string unix timestamp
this method required Bs_String. |
|
timeToUnixTimestamp |
|
public string timeToUnixTimestamp( string $time )
|
| |
converts a time into a unix timestamp. 15:10:23 -> 984665423
this function gets used by usDateToUnixTimestamp(), euDateToUnixTimestamp(), sqlDateToUnixTimestamp()because the time looks the same in all of these versions (us, eu, sql).the day, month and year of the returned timestamp will be from the current date.we are using php's built in strToTime(). hope it will get better... but should be ok for the time stuff.
|
| Parameter |
|
|
| Returns |
string unix timestamp |
|
usDatetimeToUnixTimestamp |
|
public string usDatetimeToUnixTimestamp( string $usDatetime )
|
| |
converts a us datetime into a unix timestamp. eg 2001/02/19 15:10:23 -> 982591823
we are using php's built in strToTime(). hope it will get better...
|
| Parameter |
|
|
| Returns |
string unix timestamp |
|
usDateToUnixTimestamp |
|
public string usDateToUnixTimestamp( string $usDate )
|
| |
converts a us date into a unix timestamp. eg 2001/02/19 ->
we are using php's built in strToTime(). hope it will get better...
|
| Parameter |
|
|
| Returns |
string unix timestamp |
|
usTimeToUnixTimestamp |
|
public string usTimeToUnixTimestamp( string $usTime )
|
| |
converts a us time into a unix timestamp. 15:10:23 ->
because the time looks the same in all versions (us, eu, sql) all these methods are using timeToUnixTimestamp().
|
| Parameter |
|
|
| Returns |
string unix timestamp |
| See Also |
timeToUnixTimestamp() |
|
sqlDatetimeToUnixTimestamp |
|
public string sqlDatetimeToUnixTimestamp( string $sqlDatetime )
|
| |
converts a sql datetime into a unix timestamp. eg 2001-02-19 15:10:23 -> 982591823
we are using php's built in strToTime(). hope it will get better...
|
| Parameter |
|
|
| Returns |
string unix timestamp |
| Throws |
-1 |
|
sqlDateToUnixTimestamp |
|
public string sqlDateToUnixTimestamp( string $sqlDate )
|
| |
converts a sql date into a unix timestamp. eg 2001-02-19 ->
we are using php's built in strToTime(). hope it will get better...
|
| Parameter |
|
|
| Returns |
string unix timestamp |
| Throws |
bool false |
|
sqlTimeToUnixTimestamp |
|
public string sqlTimeToUnixTimestamp( string $sqlTime )
|
| |
converts a sql time into a unix timestamp. 15:10:23 ->
because the time looks the same in all versions (us, eu, sql) all these methods are using timeToUnixTimestamp().
|
| Parameter |
|
|
| Returns |
string unix timestamp |
| See Also |
timeToUnixTimestamp() |
|
euDatetimeToUnixTimestamp |
|
public string euDatetimeToUnixTimestamp( string $euDatetime )
|
| |
converts a eu datetime into a unix timestamp. eg 19.2.2001 15:10:23 -> 982591823
we are NOT using php's built in strToTime() because it returns wrong dates for eu dates :(at least until now, 2001/02/20. hope it will improve. so we use some own php code.for the date part, we use our own euDateToUnixTimestamp() method. then we create a us date withformatUnixTimestamp(). finally we convert the us date together with the time part to a timestampusing usDatetimeToUnixTimestamp().i have tested it and a) performance is definitely NOT an issue, and b) it works quite well, evenwith a date like "15.3.1999 10:26:10" (note the extra spaces in the middle).
|
| Parameter |
|
|
| Returns |
string unix timestamp |
|
euDateToArray |
|
public array euDateToArray( string $euDate )
|
| |
converts a eu date into an array.
this method does not use the unix-timestamp, so there is no limitation in the time range.
|
| Parameter |
|
| string |
$euDate |
|
|
(31.12.2002) |
|
| Returns |
array |
| Throws |
bool FALSE (not a valid date. eg wrong syntax, or 31.03.2002) |
| See Also |
sqlDateToArray() |
|
sqlDateToArray |
|
public array sqlDateToArray( string $sqlDate )
|
| |
converts a sql date into an array.
this method does not use the unix-timestamp, so there is no limitation in the time range.
|
| Parameter |
|
| string |
$sqlDate |
|
|
(2002-12-31) |
|
| Returns |
array |
| Throws |
bool FALSE (not a valid date. eg wrong syntax, or 2002-03-31) |
| See Also |
euDateToArray() |
|
getSeparator |
|
public string getSeparator( string $date )
|
| |
tries to find the separator used in a date.
example: 2002/12/31 => /31.12.2002 => .
|
| Parameter |
|
|
| Returns |
string (char) |
| Throws |
bool FALSE (nothing found) |
|
cleanDateArray |
|
public array cleanDateArray( array $arr )
|
| |
takes a date array and cleans its elements.
if these keys don't exist, they'll be added:'year', 'month', 'day', 'hour', 'min', 'sec'
|
| Parameter |
|
|
| Returns |
array (hash) |
|
euDateToUnixTimestamp |
|
public string euDateToUnixTimestamp( string $euDate )
|
| |
converts a eu date into a unix timestamp. eg 19.2.2001 -> 982591823
we are NOT using php's built in strToTime() because it returns wrong dates for eu dates :(at least until now, 2001/02/20. hope it will improve. so we use some own php code.
|
| Parameter |
|
|
| Returns |
string unix timestamp |
|
euTimeToUnixTimestamp |
|
public string euTimeToUnixTimestamp( string $euTime )
|
| |
converts a eu time into a unix timestamp. 15:10:23 ->
because the time looks the same in all versions (us, eu, sql) all these methods are using timeToUnixTimestamp().
|
| Parameter |
|
|
| Returns |
string unix timestamp |
| See Also |
timeToUnixTimestamp() |
|
usDatetimeToEuDatetime |
|
public string usDatetimeToEuDatetime( [ string $usDatetime ] )
|
| |
converts a us datetime into a european datetime
|
| Parameter |
|
| string |
$usDatetime |
= >>''<< |
|
|
|
| Returns |
string eu datetime |
|
usDateToEuDate |
|
public string usDateToEuDate( [ string $usDate ] )
|
| |
converts a us date into a european date
|
| Parameter |
|
|
| Returns |
string eu date |
| Throws |
bs_exception or -1, both is possible. |
|
usDatetimeToSqlDatetime |
|
public string usDatetimeToSqlDatetime( [ string $usDatetime ] )
|
| |
converts a us datetime into a sql datetime
|
| Parameter |
|
| string |
$usDatetime |
= >>''<< |
|
|
|
| Returns |
string sql datetime |
|
usDateToSqlDate |
|
public string usDateToSqlDate( [ string $usDate ] )
|
| |
converts a us date into a sql date
|
| Parameter |
|
|
| Returns |
string sql date |
|
euDatetimeToUsDatetime |
|
public string euDatetimeToUsDatetime( [ string $euDatetime ] )
|
| |
converts a eu datetime into a us datetime
|
| Parameter |
|
| string |
$euDatetime |
= >>''<< |
|
|
|
| Returns |
string us datetime |
|
euDateToUsDate |
|
public string euDateToUsDate( [ string $euDate ] )
|
| |
converts a eu date into a us date
|
| Parameter |
|
|
| Returns |
string us date |
|
euDatetimeToSqlDatetime |
|
public string euDatetimeToSqlDatetime( [ string $euDatetime ] )
|
| |
converts a eu datetime into a sql datetime
|
| Parameter |
|
| string |
$euDatetime |
= >>''<< |
|
|
|
| Returns |
string sql datetime |
|
euDateToSqlDate |
|
public string euDateToSqlDate( [ string $euDate ] )
|
| |
converts a eu date into a sql date
|
| Parameter |
|
|
| Returns |
string sql date |
|
sqlDatetimeToUsDatetime |
|
public string sqlDatetimeToUsDatetime( [ string $sqlDatetime ] )
|
| |
converts a sql datetime into a us datetime eg '2001-02-28 20:54:23' -> '2001/02/28 20:54:23'
|
| Parameter |
|
| string |
$sqlDatetime |
= >>''<< |
|
|
|
| Returns |
string us datetime |
|
sqlDateToUsDate |
|
public string sqlDateToUsDate( [ string $sqlDate ] )
|
| |
converts a sql date into a us date
|
| Parameter |
|
|
| Returns |
string us date |
|
sqlDatetimeToEuDatetime |
|
public string sqlDatetimeToEuDatetime( string $sqlDatetime )
|
| |
converts a sql datetime into a european datetime
|
| Parameter |
|
|
| Returns |
string eu datetime |
|
sqlDateToEuDate |
|
public string sqlDateToEuDate( [ string $sqlDate ] )
|
| |
converts a sql date into a eu date
|
| Parameter |
|
|
| Returns |
string eu date |
|
monthStringToNumber |
|
public mixed monthStringToNumber( string $month, [ string $zeroFill ] )
|
| |
converts a month like 'Feb' or 'February' into a numerical month value (2).
takes the param $month in the languages:- english en - danish da- french fr - italian it- german de - spanish es- dutch nl - portuguese ptyou don't need to "normalize" strings, eg 'février' to 'fevrier'.for details see db-table bs_kb.LangMonth.
|
| Parameter |
|
|
|
| string |
$zeroFill |
= >>FALSE<< |
|
if set to TRUE, the return value is a 2 char string. default is FALSE. |
|
| Returns |
mixed (int 1 to 12 or string '01' to '12' depending on $zeroFill) |
| Throws |
int 0 (if not known, no match. does *not* return '00' if $zeroFill is TRUE.) |
|