如何将日期轮到00或30?

时间:2012-01-16 19:09:03

标签: php datetime

  

可能重复:
  Round formatted time value to the nearest half-hour

我有例如:

$one = 2012-01-17 13:17:00;
$two = 2012-01-17 13:13:00;
$three = 2012-01-17 13:44:00;
$four = 2012-01-17 13:54:00;

可以将此围绕到00或30吗?例如:

2012-01-17 13:17:00 == 13:30:00
2012-01-17 13:13:00 == 13:00:00
2012-01-17 13:44:00 == 13:30:00
2012-01-17 13:54:00 == 14:00:00

if < 15 then = 00
if > 15 and < 30 = 30
if > 30 and < 45 = 30
if > 45 and < 00 = +1 00

如果特别适用于此?

0 个答案:

没有答案