如果某个位置(例如澳大利亚悉尼)的当前时间在上午9点到下午5点之间,并且是工作日,我需要显示一些内容。
谢谢你的帮助
查看PHP的许多日期/时间函数
以下是我将使用的步骤:- 确定本地系统时区偏移量。
- 确定本地系统时间。
- 确定目标位置的时区偏移。
- 了解这些项目将使您能够计算目标位置的时间(减去本地偏移量,添加目标偏移量)。
- 如果结果时间在适当的边界之间,则显示内容。
$current_time_date = getdate();
$currently_in_business_hours = false;
if ($current_time_date['hours'] >= 9 && $current_time_date['hours'] < 17 && $current_time_date['wday'] != 0 && $current_time_date['wday'] != 6) {
$currently_in_business_hours = true;
}