Skip to end of metadata
Go to start of metadata

$string = currtime([$format]);

 

Returns a pre-formatted date/time string, e.g. to use in logfiles. Without parameter the format is human-readable. With parameters you can request a string that is optimized for file names, or an ISO formatted string.

ISO 8601

On using the 'iso' parameter, the returned string may not be exactly equal to the same-named Perl function in LoxBerry::System. Nevertheless both functions return an ISO compliant date string.

Locales

The function does not consider any locales. The format is hardcoded. Only for the human readable format, this may be changed in the future.

Parameters

ParameterBeschreibung
(empty) or 'hr'human readable date and time dd.mm.yyyy hh:mm:ss
'hrtime'human readable time only hh:mm:ss (available from LoxBerry 1.2.5)
'hrtimehires'human readable time only, including milliseconds hh:mm:ss.vvv (available from LoxBerry 1.2.5)
'file'Optimized for file names yyyymmdd_hhmmss
'filehires'Optimized for file names, including milliseconds: yyyymmdd_hhmmss_mmm (available from LoxBerry 1.2.5)
'iso'Following ISO 8601: yyyy-mm-ddThh:mm:ssZ

Usage

require_once 'loxberry_system.php';
 
echo "This log was started at " . currtime();
$logfile = currtime('file') . "_mylog.txt";
$json_datetime = currtime('iso')";

  • No labels