webCOMAND

time::int_to_db()

Convert Unix time to a database compatible timestamp string.

Prototype

string static int_to_db(long $timestamp)

Parameter

  • timestamp - Unix timestamp as a long integer or float with milliseconds, as returned by get_time() or microtime(TRUE).

Return

String in YYYY-MM-DD HH:MM:SS.mmm format.  The millisecond portion (.mmm) is only included if timestamp is a float with milliseconds.  If timestamp is not valid, "0000-00-00 00:00:00" is returned.

Example

// output like: Current time: 2018-10-06 22:14:13.245
$now = \io_comand_util\time::get_time();
$timestamp = \io_comand_util\time::int_to_db($now);
echo("Current time: $timestamp\n");