If i have a varible
// in minutes
$min = 40;
And i want to add it to a strotime formatted time
$strtTime = $strtotime('now') + $min;
whats the correct way to do this?
你可以这样做:
strtotime("+{$min} minutes");
Well, look at the documentation . It tells you how to use the function.
$future = strtotime('+40 minutes');
You can also be a little more concrete and include where to start from.
$future = strtotime('now + 40 minutes');
While the above is a lot easier you could also do it manually. It just involves some basic arithmetic:
$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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.