webCOMAND

time::db_timestamp_valid()

Returns TRUE if a timestamp is a valid database timestamp string in YYYY-MM-DD HH:MM:SS format, without microseconds.  Hours are in 24-hour format.  This is the standard timestamp format of most databases and the repository.  The value is not interpreted, so '0000-00-00 00:00:00' is valid.

Prototype

string static db_timestamp_valid(string $timestamp)

Parameter

  • timestamp - String that must be in YYYY-MM-DD HH:MM:SS format to be valid.

Return

TRUE if string is in YYYY-MM-DD HH:MM:SS format, including '0000-00-00 00:00:00'.  Otherwise FALSE.

Example

// output like: Current time: 2018-10-06 22:14:13 (valid)
$timestamp = \io_comand_util\time::get_db_timestamp();
$valid = \io_comand_util\time::db_timestamp_valid($timestamp);
echo("Time: $timestamp (" . ($valid ? '' : 'in') . "valid)\n");