function datetime_date_default_time

Sets a consistent time on a date without time.

The default time for a date without time can be anything, so long as it is consistently applied. If we use noon, dates in most timezones will have the same value for in both the local timezone and UTC.

Parameters

$date:

Deprecated

in drupal:8.5.0 and is removed from drupal:9.0.0. Use \Drupal\Component\Datetime\DateTimePlus::setDefaultDateTime() or \Drupal\Core\Datetime\DrupalDateTime::setDefaultDateTime() instead.

See also

https://www.drupal.org/node/2880931

File

core/modules/datetime/datetime.module, line 79

Code

function datetime_date_default_time($date) {
    @trigger_error('datetime_date_default_time() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\Component\\Datetime\\DateTimePlus::setDefaultDateTime() or \\Drupal\\Core\\Datetime\\DrupalDateTime::setDefaultDateTime() instead. See https://www.drupal.org/node/2880931.', E_USER_DEPRECATED);
    // For maximum BC before this method is removed, we do not use the
    // recommendation from the deprecation method. Instead, we call the setTime()
    // method directly. This allows the method to continue to work with
    // \DateTime, DateTimePlus, and DrupalDateTime objects (and classes that
    // may derive from them).
    $date->setTime(12, 0, 0);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.