<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
public static function getDateTimeField(
DateTime $minDate,
DateTime $maxDate,
- DateTime $defaultDate,
+ DateTime $defaultDate = null,
$label,
$id = 'datetimepicker',
$pickdate = true,
$id,
$label,
$input_text,
- '',
+ DI::l10n()->t(
+ 'Time zone: <strong>%s</strong> <a href="%s">Change in Settings</a>',
+ str_replace('_', ' ', DI::app()->getTimeZone()) . ' (GMT ' . DateTimeFormat::localNow('P') . ')',
+ DI::baseUrl() . '/settings'
+ ),
$required ? '*' : '',
'placeholder="' . $readable_format . '"'
],
'lang' => $lang,
'minfrom' => $minfrom,
'maxfrom' => $maxfrom,
- ]
+ ],
]);
return $o;
* Returns the age in years, given a date of birth and the timezone of the person
* whose date of birth is provided.
*
- * @param string $dob Date of Birth
- * @param string $owner_tz (optional) Timezone of the person of interest
+ * @param string $dob Date of Birth
+ * @param string $timezone Timezone of the person of interest
*
* @return int Age in years
* @throws \Exception
*/
- public static function getAgeByTimezone($dob, $owner_tz = ''): int
+ public static function getAgeByTimezone(string $dob, string $timezone): int
{
if (!intval($dob)) {
return 0;
}
- if (!$owner_tz) {
- $owner_tz = date_default_timezone_get();
- }
-
- $birthdate = new DateTime($dob . ' 00:00:00', new DateTimeZone($owner_tz));
+ $birthdate = new DateTime($dob . ' 00:00:00', new DateTimeZone($timezone));
$currentDate = new DateTime('now', new DateTimeZone('UTC'));
$interval = $birthdate->diff($currentDate);