オンライン予約の開始時間を選択するために、30分差の営業時間に応じてタイムスロットを印刷しています。
問題に行き詰まっています。簡単な説明を次に示します。
営業時間(始終)=10:00~17:00
スロット設定: 30分
次に、スロットのリストは次のように表示されます。
午前 10:00 - 午前 10:30 - 午前 11:00 - 午前 11:30 - 正午 - 午後 12:30 - 午後 1:00 午後 1:30 - 午後 2:00 - 午後 2:30 - 午後 3:00 - 午後 3:30 - 午後 4:00 - 午後4時30分
ハードコア$UserTimeZoneIdentifire
タイムゾーン識別子変数を使用して現在のサーバータイムゾーン時間を取得し、現在のサーバータイムゾーンの実行時間に従って過去の時間をすべて無効にします。
$UserTimeZoneIdentifire = "America/Denver";
例えば:
顧客 ' ABC ' の現在のタイムゾーン時間が:午後 12 時 33 分である場合、午前 10時から午後 12 時 33 分までのすべての時間帯が無効になり、利用可能な時間は午後 12 時 35 分(5 の倍数で分を四捨五入) から開始されます。
ここにいくつかのコード:
/**
* If appointment date is current date then get current user's timezone time
*/
$UserTimeZoneIdentifire = "America/Denver";
if(strtotime($AppointmentDate) == strtotime(date("Y-m-d"))) {
date_default_timezone_set($UserTimeZoneIdentifire);
echo $Biz_start_time = $BusinessHours['Biz_start_time']; echo "--biz start time<br>";
echo $UserCurrentTime = date("h:i A"); echo "--current server time<br>";
echo $ServerCurMinute = substr($UserCurrentTime, 3,5); echo "--strip minutes time<br>";
echo $RoundOffMinute = round(($ServerCurMinute+5/2)/5)*5; echo "--round off minutes time<br>";
if($RoundOffMinute > 55) {
/*
* If minutes are greater then 55 then add 1 hour in time
*/
$UserCurrentTime = substr_replace($UserCurrentTime, "00", 3, 2);
$UserCurrentTime = date("h:i A", strtotime("+1 hour", strtotime($UserCurrentTime)));
} else {
if($RoundOffMinute <= 5) {
$RoundOffMinute = "0".$RoundOffMinute;
}
$UserCurrentTime = substr_replace($UserCurrentTime, $RoundOffMinute, 3, 2);
}
$Biz_start_time = $UserCurrentTime;
$Biz_end_time = $BusinessHours['Biz_end_time'];
} else {
$Biz_start_time = "10:00am ";
$Biz_end_time = "05:00pm";
}
問題は、タイムゾーン識別子のハードコーディングされた値を php 変数に保存したことです。しかし、任意のタイムゾーンでハードコードされた値ではなく、動的に $UserTimeZoneIdentifire 変数を設定するために PHP を使用して現在のサーバーのタイムゾーン識別子を取得するにはどうすればよいでしょうか?
それで、あなたたちを通して感謝される助けと他のテクニックのどれでも。ありがとう。