/** * Returns the formatted birthday of this user. * * @param integer $year * @return string */ public function getBirthday($year = null) { // split date $birthdayYear = $month = $day = 0; $value = explode('-', $this->birthday); if (isset($value[0])) { $birthdayYear = intval($value[0]); } if (isset($value[1])) { $month = intval($value[1]); } if (isset($value[2])) { $day = intval($value[2]); } if (!$month || !$day) { return ''; } $d = new \DateTime(); $d->setTimezone(WCF::getUser()->getTimeZone()); $d->setDate($birthdayYear, $month, $day); $dateFormat = $this->birthdayShowYear && $birthdayYear ? WCF::getLanguage()->get(DateUtil::DATE_FORMAT) : str_replace('Y', '', WCF::getLanguage()->get(DateUtil::DATE_FORMAT)); $birthday = DateUtil::localizeDate($d->format($dateFormat), $dateFormat, WCF::getLanguage()); if ($this->birthdayShowYear) { $age = $this->getAge($year); if ($age > 0) { $birthday .= ' (' . $age . ')'; } } return $birthday; }