0

I have two dates: 2022-11-11 and 2022-12-12

How can I loop all of the days between these dates and output every day in unixtimestamp format?

Thanks.

I searched a lot online but all the solutions return dates in string format i.e.

Thursday 2022-12-08 00:00:00

  • So what about turning that string format into unix format then? If done in a way it works for the format you can do it once or more, so should fit in a loop. Have you tried that? – hakre Dec 09 '22 at 11:23
  • See here for how to loop between two dates: https://stackoverflow.com/questions/3207749/i-have-2-dates-in-php-how-can-i-run-a-foreach-loop-to-go-through-all-of-those-d – user1915746 Dec 09 '22 at 11:26
  • i tried strtotime($date) but it gives an error that datetime object cannot be converted – Mishel Jordon Dec 09 '22 at 11:26
  • @user1915746 its not what I want I want the output in unix format – Mishel Jordon Dec 09 '22 at 11:28
  • If you already have a Datetime object you can use $date->getTimestamp() – user1915746 Dec 09 '22 at 11:39

0 Answers0