webCOMAND

time::format_timestamp()

Format a time into the standard webCOMAND time format.  The time can be expressed as a database timestamp, Unix time or any format recognized by strtotime().

Prototype

string static format_timestamp(mixed $time, string $invalid = 'never')

Parameter

  • time - A time expressed as a database timestamp, Unix time or any format recognized by strtotime().
  • invalid - String to display if a "zero" or invalid timestamp is provided.

Return

String the standard webCOMAND format, which is M/D/YYYY H:M:S(am|pm) by default but can be customized in config.php.

Example

// output like: Current time: 10/6/2018 10:14:13pm
$now = \io_comand_util\time::get_time();
$formatted = \io_comand_util\time::format_timestamp($now);
echo("Current time: $formatted\n");