Skip to content

moonset occasionally causing fatal erorr #13

Description

@dmvictoria

Hi!

I have a site with every location in the world and I use suncalc to display sunrise/sunset moonrise/moonset. But randomly, several locations every day will get a fatal error and not load:

Fatal error: Call to a member function format() on a non-object in...

It seems only the moonset object is missing, the other sunrise/sunset and moonrise objects load fine. For now my fix is this:

if(is_object($moonTimes['moonset']))
{
	$moonset = $moonTimes['moonset']->format($hour_min_format);
}

at least that stops my page from crashing.

Thanks.

PS love the script by the way :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions