I have two dates starting date and end date. How to get range of days from these two dates?
Thanks!
Asked
Active
Viewed 88 times
1 Answers
1
You should user DatePeriod class and example:
$period = new \DatePeriod(
new \DateTime('2010-10-01'),
new \DateInterval('P1D'),
new \DateTime('2010-10-05')
);

Osama Sayed
- 1,993
- 15
- 15
-
Ok, but when I try to pass it to my view I'm using @foreach($period as $period) {{$period}} @endforeach and I have an error "htmlentities() expects parameter 1 to be string, object given" – Martin Jun 20 '16 at 11:23
-
Okay, I've solved it out. – Martin Jun 20 '16 at 11:27