예제 #1
0
 public function get()
 {
     $dateTime = DateTime::set($this->date, null, $this->config);
     if (isset($this->timezone)) {
         $dateTime->convertTimezone($this->timezone);
     }
     return $dateTime->format($this->format);
 }
예제 #2
0
 /**
  * Modify date.
  *
  * @param string $date date
  * @param array $params params:
  *
  * - format: date format
  * - locale: date locale.
  *
  * @return string|null
  */
 public static function modifyDate($date, array $params = [])
 {
     if (empty($date)) {
         return null;
     }
     $params['config'] = Helper::getValue($params['config'], []);
     if (!empty($params['locale'])) {
         $params['config']['locale'] = $params['locale'];
     }
     $dateTime = DateTime::set($date, null, $params['config']);
     if (isset($params['timezone'])) {
         $dateTime->convertTimezone($params['timezone']);
     }
     return $dateTime->format(Helper::getValue($params['format']));
 }
예제 #3
0
 public function afterLogin()
 {
     $users = $this->getUsers();
     $users->login_last = DateTime::set()->isoDatetime();
     if (!$users->save()) {
         $this->addError('alerts', i18n::t('failLogin'));
         return;
     }
     $event = new ModelEvent();
     $event->result = $users;
     $this->trigger(self::EVENT_AFTER_LOGIN, $event);
 }