I have automatic tasks in the system when the status of the client changes, a task is automatically set up that has the value “run in N hours,” for example, in 480 minutes.

Well, an example of the time when the status was set: 2015-04-24 16:51:06

You need by the time 2015-04-24 16:51:06 round up to 2015-04-24 16:50:00 or if 2015-04-24 16:53:06 then in 2015-04-24 16:55:00

Since the task check step is 5 minutes.

And i.e. by 2015-04-24 16:55:00 already add 480 minutes

Help solve the problem

    1 answer 1

    Since 5 minutes is 300 seconds,

    $time = round($timestamp / 300) * 300; 

    If you need the current time point $timestamp=time()

    If you have time in dateTime format then $timestamp= date_timestamp_get($date); or $timestamp=$date->getTimestamp();

    • Explain the work ... It is necessary to round by 2015-04-24 16:51:06 to 2015-04-24 16:50:00 or if 2015-04-24 16:53:06 then in 2015-04-24 16 : 55: 00 - Alexander Sizintsev
    • @AlexanderSizintsev in what time format? Datetime? or text? - Crantisz
    • all done thank you very much. - Alexander Sizintsev