如果我有一个可变
// in minutes
$min = 40;
我想把它添加到strotime格式的时间中
$strtTime = $strtotime('now') + $min;
正确的方法是什么?
您可以这样做:
strtotime("+{$min} minutes");
没有什么:
echo strtotime("+40 minutes");
在操作中查看
好吧,看看文档。它告诉你如何使用这个函数。
$future = strtotime('+40 minutes');
你也可以更具体一点,包括从哪里开始。
$future = strtotime('now + 40 minutes');
虽然上面的操作要简单得多,但你也可以手动完成。它只涉及一些基本的算术:
$now = time(); // Seconds since 1970-01-01 00:00:00
$minutes = 40;
$seconds = ($minutes * 60); // 2400 seconds
$future = ($now + $seconds);
$min = 40;
我想把它添加到strotime格式的时间中
$strtTime = strtotime("+".$min." minutes", strtotime('now'));//eg +40 minutes