Loop through Dates and Times

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Loop through Dates and Times

Post by GeXus »

Would anyone know how to loop through dates and increment seconds?

For example, I have a start date/time stamp of 2010-15-07 15:10:30

I'd like to loop through this say 10 times each time adding 30 seconds to the second value.

Thanks!
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Loop through Dates and Times

Post by superdezign »

If all you want to do is add 30 seconds to a date/time that you have a timestamp for (i.e. from the strtotime() function), you could just add 30 to the timestamp. The timestamp is the number of seconds since the Unix Epoch.

Otherwise, the mktime() function may prove useful.
Post Reply