1.20.x date.inc | date_now($timezone = NULL, $reset = FALSE) |
A date object for the current time.
Parameters
object $timezone: (optional) Optionally force time to a specific timezone, defaults to user timezone, if set, otherwise site timezone. Defaults to NULL.
bool $reset: (optional) Static cache reset.
Return value
BackdropDateTime: The current time as a date object.
File
- includes/
date.inc, line 750 - Date API functions and constants.
Code
function date_now($timezone = NULL, $reset = FALSE) {
$now = &backdrop_static(__FUNCTION__ . $timezone);
if (!isset($now) || $reset) {
$now = new BackdropDateTime('now', $timezone);
}
// Avoid unexpected manipulation of cached $now object
// by subsequent code execution
// @see https://drupal.org/node/2261395
$clone = clone $now;
return $clone;
}