How to round unix timestamp up and down to nearest half hour?

后端 未结 10 2116
名媛妹妹
名媛妹妹 2020-12-14 17:16

Ok so I am working on a calendar application within my CRM system and I need to find the upper and lower bounds of the half an hour surrorunding the timestamp at which someb

10条回答
  •  猫巷女王i
    2020-12-14 17:54

    Use modulo.

    $prev = 1330518155 - (1330518155 % 1800);
    $next = $prev + 1800;
    

    The modulo operator gives the remainder part of division.

提交回复
热议问题