在php中将变量传递给strotime

在php中将变量传递给strotime,php,Php,我的问题是,当我在数据库中获得持续时间,例如每小时15分钟,并且这些值存储在变量中,然后这些变量被传递到strotime(“+15分钟”),那么它们就会出错。我如何解决这个问题 我的代码在这里: $custom = $book_u['custom_min'] = $row['custom_min']; $start_time=explode(',',$row['start_time']); while($t==0) { $t=1; $endTime2 = strtotime("+

我的问题是,当我在数据库中获得持续时间,例如每小时15分钟,并且这些值存储在变量中,然后这些变量被传递到strotime(“+15分钟”),那么它们就会出错。我如何解决这个问题

我的代码在这里:

$custom = $book_u['custom_min'] = $row['custom_min'];
$start_time=explode(',',$row['start_time']);
while($t==0)
{
    $t=1;
    $endTime2 = strtotime("+1".$custom."minutes", strtotime($endTime));
    $starts_t[]=date('h:i a', strtotime($endTime));
    $ends_t[]=date('h:i a', $endTime2);
    //echo  date('h:i a', strtotime($endTime)).'-'.date('h:i a', $endTime2).'</br>';
    $endTime=date('h:i a', strtotime("+15 mins", $endTime2));
    if(strtotime($endTime)>strtotime($finalTime)){
        $t=1;
    }
else $t=0;
}   
$custom=$book\u['custom\u min']=$row['custom\u min'];
$start_time=explode(“,”,$row['start_time']);
而($t==0)
{
$t=1;
$endTime2=strottime(“+1”。$custom.“分钟”,strottime($endTime));
$starts_t[]=日期('h:i a',strottime($endTime));
$ends_t[]=日期('h:i a',$endTime2);
//回显日期('h:ia',strottime($endTime)).-'.date('h:ia',$endTime2)。'
'; $endTime=date('h:ia',strottime(+15分钟,$endTime2)); if(strotime($endTime)>strotime($finalTime)){ $t=1; } 否则$t=0; }
函数将生成一个时间戳,该时间戳等于1970年1月1日00:00:00 UTC以来相对于时间戳的秒数

因此,输入函数的值必须始终至少包含一个日期。仅使用时间值会导致问题

以下是如何使用该函数的示例:

$endTime = '2018-08-10 22:00:00';  //End time must be a date reference.
//Using just a time like 22:00:00 will cause you problems.

$custom = '15'; //Number of minutes
$end_t = date('h:i a', strtotime($endTime . ' +' . $custom . ' minutes'));
//Notice where the spaces are. The strtotime() part will read "2018-08-10 22:00:00 +15 minutes"

echo $end_t; //outputs "10:15 pm" 

您获取的错误是什么面对此错误此页面无法工作dogselan.com当前无法处理此请求。HTTP错误500不工作此代码兄弟任何其他解决方案我正在尝试此代码,但它不工作任何人可以帮助我吗$startTime=“01:00 PM”$finalTime=“04:25 PM”$海关=20$endTime=$startTime$t=0;而($t==0){$t=1;$endTime2=date('+'.$custom.'minutes',strotime($endTime));//$endTime2=date('h:ia',strotime('endTime.'+'.$custom.'minutes');$array[]=date('h:ia',strotime($endTime)).-'
';$endTime=date('h:ia',$endTime2);if('strotime($endTime($endTime)>strotime($finalTime){$else$t=0;}$test=$array;打印(测试);