Koha::DateUtils - Transitional wrappers to ease use of DateTime
Koha has historically only used dates not datetimes and been content to handle these as strings. It also has confused formatting with actual dates this is a temporary module for wrappers to hide the complexity of switch to DateTime
$dt = dt_from_string($date_string, [$format, $timezone ]);
Passed a date string returns a DateTime object format and timezone default to the system preferences. If the date string is empty DateTime->now is returned
$date_string = output_pref($dt, [$format] );
Returns a string containing the time & date formatted as per the C4::Context setting
A second parameter allows overriding of the syspref value. This is for testing only In usage use the DateTime objects own methods for non standard formatting
$date_string = output_pref_due($dt, [$format] );
Returns a string containing the time & date formatted as per the C4::Context setting
A second parameter allows overriding of the syspref value. This is for testing only In usage use the DateTime objects own methods for non standard formatting
This is effectivelyt a wrapper around output_pref for due dates the time portion is stripped if it is '23:59'
$string = format_sqldatetime( $string_as_returned_from_db );
a convenience routine for calling dt_from_string and formatting the result with output_pref as it is a frequent activity in scripts
$string = format_sqldatetime( $string_as_returned_from_db );
a convenience routine for calling dt_from_string and formatting the result with output_pref_due as it is a frequent activity in scripts