You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< ? php
namespace App\Lib ;
use DateTime ;
use Illuminate\Support\Facades\Http ;
use Illuminate\Support\Facades\Log ;
class Tools
{
//查询某天是星期几
public static function GetWeekName ( $date )
{
$dayOfWeek = date ( 'N' , strtotime ( $date )); // 获取星期几, 1代表星期一, 7代表星期日
$weekname = '' ;
switch ( $dayOfWeek ) {
case 1 :
$weekname = " 星期一 " ;
break ;
case 2 :
$weekname = " 星期二 " ;
break ;
case 3 :
$weekname = " 星期三 " ;
break ;
case 4 :
$weekname = " 星期四 " ;
break ;
case 5 :
$weekname = " 星期五 " ;
break ;
case 6 :
$weekname = " 星期六 " ;
break ;
case 7 :
$weekname = " 星期日 " ;
break ;
default :
$weekname = " 无效日期 " ;
}
return $weekname ;
}
public static function SendMsg ( $r_yyid , $tel , $name , $time ){
if ( $r_yyid == 1 ){
$yyid = 6 ;
}
if ( $r_yyid == 4 ){
$yyid = 2 ;
}
$content = " 时间: " . $time . " ;科室:健康管理中心1区。温馨提醒:您的预约已成功,请在预约时间前 30 分钟达到科室, 凭身份证原件开单。建议您体检前3天清淡饮食、禁烟酒 " ;
$url = " http://220.174.210.111:82/tuisong.aspx?yyid= " . $yyid . " &type=8&mobile= " . $tel . " &msg1= " . urlencode ( $name ) . " &msg2= " . urlencode ( $content );
$response = Http :: get ( $url );
if ( $response -> successful ()) {
} else {
Log :: info ( " 短信发送失败 " );
}
}
//根据生日 获取年龄
public static function GetAge ( $birthday ) {
$dob = new DateTime ( $birthday );
$now = new DateTime ();
// 计算两个日期之间的差值
$interval = $now -> diff ( $dob );
// 返回年龄
return $interval -> y ;
}
}