Example #1
0
 /**
  * 获取日期年份
  * @param string $str 时间字符串
  * @author wjh
  * @version 2014-4-26
  */
 public static function getYear($dt = null)
 {
     $dt = empty($dt) ? BDataHelper::getCurrentTime() : $dt;
     return date('Y', strtotime($dt));
 }
Example #2
0
 /**
  * 根据出生日期获取用户今天是否生日、生日日期及几天后生日
  * @author lvkui 2014-12-02
  * @param $brithday 出生日期
  * @return array
  */
 public static function getBirthdayInfoBydate($brithday)
 {
     $result = array();
     if (empty($brithday)) {
         $result['birthday'] = '';
         $result['flag'] = false;
         $result['count'] = '';
         return $result;
     }
     $tmonth = substr($brithday, 5, 2);
     $tday = substr($brithday, 8, 2);
     $nowYear = BDataHelper::getCurrentTime('Y');
     $result['birthday'] = $tmonth . '-' . $tday;
     //生日 月日
     $newBirthday = strtotime($nowYear . '-' . $result['birthday']);
     //生日的时间
     $nowShortTime = strtotime(BDataHelper::getCurrentTime('Y-m-d'));
     //当前时间
     $agoShortTime = strtotime(date('Y-m-d', $nowShortTime) . ' 23:59:59') + 7 * 3600 * 24;
     if ($newBirthday >= $nowShortTime && $newBirthday <= $agoShortTime) {
         $result['flag'] = true;
     } else {
         $result['flag'] = false;
     }
     $count = ($newBirthday - $nowShortTime) / 3600 / 24;
     $result['count'] = $count;
     $result['old'] = $brithday;
     return $result;
 }