0

Trying to understand how to write this function to get a 6-day forecast for 2 days from now. Right now it returns an 8 day forecast including today. If I give it the atTime it gives me one forecast during that day. I'm using php (laravel)

        $two_days_forcast = Carbon::now()->addDay(2)->timestamp;

    if ($users->latitude) {
        $weather = DarkSky::location($users->latitude, $users->longitude)
        ->atTime($two_days_forcast)
        ->daily();
        return $weather;

Any help would be appreciated. If I don't add the ->atTime it gives me the 8 day forecast.

vvp24
  • 25
  • 8
  • Why don't just slice the original array? BTW, if you put an array of all the days in th atTime function what happens?? – ItsEdgar94 Feb 29 '20 at 00:30
  • if you mean something like this $two_days_forcast = Carbon::now()->addDay(2)->timestamp; $three_days_forcast = Carbon::now()->addDay(3)->timestamp; if ($users->latitude) { $weather = DarkSky::location($users->latitude, $users->longitude) ->atTime([$two_days_forcast,$three_days_forcast]) ->daily(); return $weather; } else { then it throws a Notice: Array to string conversion – vvp24 Feb 29 '20 at 00:51

0 Answers0