Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

leonidas's avatar

Store time intervals in database

Hello,

What is the most appropriate/efficient way of storing time intervals in a database? I will be using the laravel scheduler. I have a start and end date - but I need to store a frequency between these dates - eg. daily, weekly, fortnightly - for the scheduler.

I was thinking of having another time stamp - last_executed - where the time difference between now and the frequency + last_executed > 0 the scheduler would execute the job?

In this case in what format would you store the frequency? Is there a more efficient way?

Thanks

0 likes
2 replies
D9705996's avatar
D9705996
Best Answer
Level 51

If you are storing a frequency I would just store it in seconds as an integer, e.g. 86400 = daily. You can then do maths on it

leonidas's avatar

I think this was the approach I was going to take.

I have set the database up in this manner however have come across an issue regarding the Carbon library, but I think I will start a new question.

Please or to participate in this conversation.