1

時間の違いを見つける方法、たとえば、予定の時間は

午後 4 時 30 分ですが、cron ジョブで 30 分、15 分、または 5 分で通知を送信したい

午後4時30分まで

しかし、30分に設定されている場合、メールが午後4時に送信される場合に通知するifステートメントを作成できるように、時差を取得する方法がわかりません

元:

$setting = "30 minute";//set to notify 30 min before appointment
$notiftime = "4:30 PM";//time of the appointment

$notiftime = strtotime($notiftime);
$difference = strtotime( '-' $setting , $notiftime);

$current = date('h:ia'); //gets current time
$current = strtotime($current);

if ( $current <= $difference){ 

//send email script=======

} 
4

2 に答える 2

1

$settingは文字列であるため、機能することはできません- $setting-文字列自体にを追加する必要があります。

$difference = strtotime('-' . $setting , $notiftime);
于 2012-11-25T11:48:45.690 に答える
1

これがあなたが望むものです:

$appointment = "4:30 PM";//time of the appointment
$delay = 30 * 60; //set to notify 30 min before appointment

$appointment = strtotime($appointment);
$notifytime = date('h:ia', $appointment - $delay);
于 2012-11-25T12:02:44.783 に答える