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

后端 未结 10 2043
名媛妹妹
名媛妹妹 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条回答
  •  天涯浪人
    2020-12-14 17:32

    You could use the modulo operator.

    $time -= $time % 3600; // nearest hour (always rounds down)
    

    Hopefully this is enough to point you in the right direction, if not please add a comment and I'll try to craft a more specific example.

提交回复
热议问题