Php 如何在另一个STROTIME之前完成STROTIME?

Php 如何在另一个STROTIME之前完成STROTIME?,php,Php,我现在还在学习php语言,我想做的是在if..else语句中,但是在if语句中我需要检查this直到this time only available else错误,我能知道如何让这段代码完成吗 我的代码: $thistime=date("h:i:s",strtotime("10:00 am")); $untiltime=date("h:i:s",strtotime("11:00 am")); if(){ echo blablabla; } else{echo error;}; 谢谢,希望你们

我现在还在学习php语言,我想做的是在if..else语句中,但是在if语句中我需要检查this直到this time only available else错误,我能知道如何让这段代码完成吗

我的代码:

$thistime=date("h:i:s",strtotime("10:00 am"));
$untiltime=date("h:i:s",strtotime("11:00 am"));

if(){ echo blablabla; } else{echo error;};
谢谢,希望你们尽快回复我,非常简单

 $thistime = date("h:i:s", strtotime("10:00 am"));
 $untiltime=date("h:i:s", strtotime("11:00 am"));

 if(strtotime("10:00 am") < strtotime("11:00 am"))
 { 
     echo "blablabla"; 
 } else {
     echo "error";
 };
$thistime=日期(“h:i:s”,标准时间(“上午10:00”);
$untiltime=日期(“h:i:s”,标准时间(“上午11:00”);
如果(标准时间(“上午10:00”)<标准时间(“上午11:00”))
{ 
呼应“布拉布拉”;
}否则{
回声“错误”;
};

我假设您每天只允许在一定时间内访问特定内容,特别是在上午10点到11点之间。如果是这样的话,那么你就走上了正确的道路,但我会尽力为你澄清一些事情

strotime()
函数将字符串解释为给定的秒,并返回Unix时间戳(UTC时区中自1970年1月1日午夜以来的秒数)。您可以使用这些时间戳设置时间范围的开始和结束标记

date()
函数用于将时间戳格式化为特定格式。代码中的
h:i:s
格式表示一天中的当前小时、分钟和秒,每个值之间都有冒号分隔符。虽然此函数很有用,但它在您尝试执行的操作中没有任何作用,因为时间戳是比较的更好选项

您需要了解的最后一个函数是
time()
。此函数返回代码运行时的Unix时间戳。将此值与使用
strotime()
定义的起点和终点进行比较,以确定是否显示页面

将所有这些放在一起,我们得到以下代码:

// define the range in which the page is allowed to display
$rangeStart = strtotime("10:00 AM");
$rangeEnd   = strtotime("11:00 AM");

// define a variable with the current time
$now = time();

// compare the current time to the two range points
// to determine if the current time is within the display range

if ($now >= $rangeStart && $now <= $rangeEnd) {
  // display page
} else {
  // display error message
}
//定义允许页面显示的范围
$rangeStart=strottime(“上午10:00”);
$rangeEnd=标准时间(“上午11:00”);
//使用当前时间定义变量
$now=时间();
//将当前时间与两个范围点进行比较
//确定当前时间是否在显示范围内
如果($now>=$rangeStart&&$now