本文整理汇总了PHP中XenForo_Locale::getFormattedDate方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Locale::getFormattedDate方法的具体用法?PHP XenForo_Locale::getFormattedDate怎么用?PHP XenForo_Locale::getFormattedDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Locale
的用法示例。
在下文中一共展示了XenForo_Locale::getFormattedDate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculateAge
/**
* Calculates the age of the person with the specified birth date.
*
* @param integer $year
* @param integer $month
* @param integer $day
*
* @return integer
*/
public function calculateAge($year, $month, $day)
{
list($cYear, $cMonth, $cDay) = explode('-', XenForo_Locale::getFormattedDate(XenForo_Application::$time, 'Y-m-d'));
$age = $cYear - $year;
if ($cMonth < $month || $cMonth == $month && $cDay < $day) {
$age--;
}
return max(0, $age);
}
示例2: _render
protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
{
$core = WidgetFramework_Core::getInstance();
/** @var XenForo_Model_User $userModel */
$userModel = $core->getModelFromCache('XenForo_Model_User');
/** @var XenForo_Model_UserProfile $userProfileModel */
$userProfileModel = $core->getModelFromCache('XenForo_Model_UserProfile');
$todayStart = XenForo_Locale::getDayStartTimestamps();
$todayStart = $todayStart['today'];
$day = XenForo_Locale::getFormattedDate($todayStart, 'd');
$month = XenForo_Locale::getFormattedDate($todayStart, 'm');
$conditions = array(WidgetFramework_XenForo_Model_User::CONDITIONS_DOB => array('d' => $day, 'm' => $month), 'user_state' => 'valid', 'is_banned' => false);
$fetchOptions = array('order' => 'username', 'join' => XenForo_Model_User::FETCH_USER_PROFILE + XenForo_Model_User::FETCH_USER_OPTION);
if (!empty($widget['options']['limit'])) {
$fetchOptions['limit'] = $widget['options']['limit'];
}
if (!empty($widget['options']['avatar_only'])) {
$conditions[WidgetFramework_XenForo_Model_User::CONDITIONS_HAS_AVATAR] = true;
}
$users = $userModel->getUsers($conditions, $fetchOptions);
foreach (array_keys($users) as $userId) {
$user =& $users[$userId];
if (!empty($widget['options']['whitelist_user_groups'])) {
// check for whitelist user groups
if (!$userModel->isMemberOfUserGroup($user, $widget['options']['whitelist_user_groups'])) {
unset($users[$userId]);
continue;
}
}
if (!empty($widget['options']['blacklist_user_groups'])) {
// check for blacklist user groups
if ($userModel->isMemberOfUserGroup($user, $widget['options']['blacklist_user_groups'])) {
unset($users[$userId]);
continue;
}
}
// we can call XenForo_Model_User::prepareUserCard instead
$user['age'] = $userProfileModel->getUserAge($user);
}
$renderTemplateObject->setParam('users', array_values($users));
return $renderTemplateObject->render();
}
示例3: getLanguageFormatExamples
/**
* Generates the date and time format examples based on the
* current time.
*
* @return array [0] => date formats, [1] => time formats; keyed by format string
*/
public function getLanguageFormatExamples()
{
$dateFormatsRaw = array('M j, Y', 'F j, Y', 'j M Y', 'j F Y', 'j/n/y', 'n/j/y');
$dateFormats = array();
foreach ($dateFormatsRaw as $dateFormat) {
$dateFormats[$dateFormat] = XenForo_Locale::getFormattedDate(XenForo_Application::$time, $dateFormat);
}
$timeFormatsRaw = array('g:i A', 'H:i');
$timeFormats = array();
foreach ($timeFormatsRaw as $timeFormat) {
$timeFormats[$timeFormat] = XenForo_Locale::getFormattedDate(XenForo_Application::$time, $timeFormat);
}
return array($dateFormats, $timeFormats);
}