diff --git a/wire/core/WireDatabasePDO.php b/wire/core/WireDatabasePDO.php index 01795ce2..c400d759 100644 --- a/wire/core/WireDatabasePDO.php +++ b/wire/core/WireDatabasePDO.php @@ -1711,5 +1711,19 @@ class WireDatabasePDO extends Wire implements WireDatabase { return $result; } + /** + * Get current date/time ISO-8601 string or UNIX timestamp according to database + * + * @param bool $getTimestamp Get unix timestamp rather than ISO-8601 string? (default=false) + * @return string|int + * @since 3.0.183 + * + */ + public function getTime($getTimestamp = false) { + $query = $this->query('SELECT ' . ($getTimestamp ? 'UNIX_TIMESTAMP()' : 'NOW()')); + $value = $query->fetchColumn(); + return $getTimestamp ? (int) $value : $value; + } + }