function _quiz_mktime in Quiz 8.4
Same name and namespace in other branches
- 5.2 quiz_datetime.inc \_quiz_mktime()
- 5 quiz_datetime.inc \_quiz_mktime()
- 6.6 quiz_datetime.inc \_quiz_mktime()
- 6.2 quiz_datetime.inc \_quiz_mktime()
- 6.3 quiz_datetime.inc \_quiz_mktime()
- 6.4 quiz_datetime.inc \_quiz_mktime()
- 6.5 quiz_datetime.inc \_quiz_mktime()
- 7 quiz_datetime.inc \_quiz_mktime()
- 7.4 quiz_datetime.inc \_quiz_mktime()
Formats local time values to GMT timestamp using time zone offset supplied. All time values in the database are GMT and translated here prior to insertion.
Time zone settings are applied in the following order: 1. If supplied, time zone offset is applied 2. If user time zones are enabled, user time zone offset is applied 3. If neither 1 nor 2 apply, the site time zone offset is applied
Parameters
$hour:
$minute:
$second:
$month:
$day:
$year:
$offset: Time zone offset to apply to the timestamp.
Return value
timestamp
1 call to _quiz_mktime()
- quiz_translate_form_date in ./
quiz_datetime.inc - @file Handles the start and end times in a node form submission.
File
- ./
quiz_datetime.inc, line 52 - Handles the start and end times in a node form submission.
Code
function _quiz_mktime($hour, $minute, $second, $month, $day, $year, $offset = NULL) {
//D8 way to load $user. Instead "global $user";
$user = \Drupal::currentUser();
//print $user->timezone. " and ". variable_get('date_default_timezone', 0);
$timestamp = gmmktime($hour, $minute, $second, $month, $day, $year);
if (\Drupal::config('quiz.settings')
->get('configurable_timezones') && $user
->id() && strlen($user
->getTimeZone())) {
return $timestamp - $user
->getTimeZone();
}
else {
return $timestamp - \Drupal::config('quiz.settings')
->get('date_default_timezone');
}
}