Beispiel #1
0
 public function getNowDate()
 {
     $this->load->library('lunar');
     $lunar = new Lunar();
     $month = $lunar->convertSolarToLunar(date('Y'), date('m'), date('d'));
     $weekArr = array("日", "一", "二", "三", "四", "五", "六");
     $week = "星期" . $weekArr[date("w")];
     return date('Y') . '年' . date('m') . '月' . date('d') . '日' . ' ' . $week . ' ' . $month[3] . '年 ' . $month[1] . $month[2];
 }
 function get($string)
 {
     $lunar = new Lunar();
     $d = $lunar->convertSolarToLunar(date('Y'), date('m'), date('d'));
     $jr = $lunar->getFestival(date('Y-m-d'));
     $str = date('Y-m-d H:i:s') . "\n农历:" . $d[3] . '[' . $d[6] . ']年' . $d[1] . $d[2];
     if (!empty($jr)) {
         $str .= "\n今天是:" . $jr;
     }
     return array('code' => 1, 'msg' => $str);
 }
Beispiel #3
0
 public function birthday()
 {
     $this->logFileName = 'birthday';
     //生日提醒锁
     $cache = new Cache('remind_birthday');
     if ($cache->get('lock')) {
         return false;
     } else {
         $cache->set('lock', true, 86000);
     }
     $zh2num = ['零' => 0, '一' => 1, '二' => 2, '三' => 3, '四' => 4, '五' => 5, '六' => 6, '七' => 7, '八' => 8, '九' => 9];
     $lunar = new \Lunar();
     $date = $lunar->convertSolarToLunar(date('Y'), date('m'), date('d'));
     $sql = "SELECT `sid`, `name`, `phone`, `mail`, `birthday` FROM `student`\n                  WHERE (`birthday` LIKE ? OR `birthday` LIKE ?)\n                  AND `sid` IN (SELECT `uid` FROM `user`)";
     $arr = array('____' . date('md'), '____' . $date[1] . $date[2]);
     $users = Mysql::execute($sql, $arr);
     $group = new \Hnust\Analyse\Group();
     foreach ($users as $user) {
         if (is_numeric($user['birthday'])) {
             $year = (int) substr($user['birthday'], 0, 4);
         } else {
             $year = 0;
             for ($i = 0; $i < 4; $i++) {
                 $year *= 10;
                 $year += $zh2num[mb_substr($user['birthday'], $i, 1, 'utf-8')];
             }
         }
         //计算所属群组
         $groups = ['Tick网络工作室'];
         $belong = $group->belong($user['sid']);
         foreach ($belong as $item) {
             if (!in_array($item['name'], $groups)) {
                 $groups[] = $item['name'];
             }
         }
         $user['sms'] = array('name' => $user['name'], 'age' => (string) (date('Y') - $year), 'group' => implode('、', $groups), 'template' => 'SMS_7745798');
         $this->remind($user, '生日快乐', '生日快乐', '', '0001');
     }
     $this->record("=== 生日提醒执行完成 ===");
 }
Beispiel #4
0
<?php

header('Access-Control-Allow-Origin: *');
header("Content-Type:text/javascript;charset=utf-8");
$lunar = new Lunar();
$year = date("Y");
$month = date("n");
$day = date("j");
$ldate = $lunar->convertSolarToLunar($year, $month, $day);
echo 'lunar({"year":"' . $ldate[0] . '","month":"' . $ldate[1] . '","day":"' . $ldate[2] . '","zodiac":"' . $ldate[6] . '","sign":"' . $ldate[3] . '"})';
Beispiel #5
0
<?php

header("Content-Type:text/html;charset=utf-8");
require 'lunar.php';
$LIUREN = ["大安", "留连", "速喜", "赤口", "小吉", "空亡"];
$user_time = $_POST["user_time"];
$msg = $user_time . "<br/>";
function multiexplode($delimiters, $string)
{
    $ready = str_replace($delimiters, $delimiters[0], $string);
    $launch = explode($delimiters[0], $ready);
    return $launch;
}
$timeArray = multiexplode(array("-", "T", ":", "+", " "), $user_time);
$lunar = new Lunar();
$lunarDate = $lunar->convertSolarToLunar($timeArray[0], $timeArray[1], $timeArray[2]);
if ($lunarDate[7] > 0) {
    if ($lunarDate[4] > $lunarDate[7]) {
        $lunarDate[4] = $lunarDate[4] - 1;
    }
}
$msg = $msg . $lunarDate[1] . $lunarDate[2] . "<br/>";
//echo "<br/>".$lunarDate[4].$lunarDate[5]."<br/>";
$mm = (int) $lunarDate[4];
if ($mm > 6) {
    $mmi = ($mm - 1) % 6;
} else {
    $mmi = $mm - 1;
}
//echo $mmi.":".$LIUREN[$mmi]."月<br/>";
$dd = (int) $lunarDate[5];