• Resolved danielb1

    (@danielb1)


    Hi.

    I am unable to display the correct time for the sunrise and sunset. The location seems to be set correctly as is the PHP timezone (Europe/Berlin), but these times are off by 2 hours. I set the checkmark “Verwende aktuelle Zeit / Zeitkorrektur” and set it to 120 minutes in the corresponding input field. This corrects the current time, but does not affect the other time.

    Best regards
    Daniel

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author tuxlog

    (@tuxlog)

    Hi Daniel,

    do you use accuweather or DarkSky? And can you give the location please?

    Thread Starter danielb1

    (@danielb1)

    Hi tuxlog.

    Thank you for the swift reply. At the moment we use AccuWeather. The location is Deutsch Evern, a small town near Lüneburg.

    Best regards
    Daniel

    Plugin Author tuxlog

    (@tuxlog)

    Hi Daniel,

    just tried it and got
    sunrise: 6:55
    sunset: 19:34

    Seems to be okay for me.

    WordPress – Timezone was Berlin.
    What timezone do you use for WordPress? (Einstellungen -> Allgemein)

    Thread Starter danielb1

    (@danielb1)

    Hi tuxlog.

    We also use “Berlin” as timezone in WordPress. Strangely only the sunset and sunrise are off by two hours. Right now it shows as followed:

    Deutsch Evern
    Mittwoch, 16. September 2020, 14:19

    NW
    Heiter
    24°C
    14 km/h
    Gefühlte Temperatur: 24°C
    Aktueller Luftdruck: 1020 mb
    Luftfeuchtigkeit: 58%
    Wind: 14 km/h NW
    B?en: 25 km/h
    UV-Index: 3
    Sonnenaufgang: 4:54
    Sonnenuntergang: 17:31

    Best regards
    Daniel

    Plugin Author tuxlog

    (@tuxlog)

    Thanks again, I was able to find the reason. It is the PHP timezone set to Europe/Berlin. If set to UTC the sunset/sunrise times are shown correctly.

    I will dig into this to find why it is converted this way.

    Plugin Author tuxlog

    (@tuxlog)

    okay, think I found the problem. I use date_i18n function to convert the date of sunset and sunrise. I just found out that date_i18n has issues with certain timezone settings, such as numerical ones…

    I will try to use another date conversion to fix it.

    Plugin Author tuxlog

    (@tuxlog)

    Can you please try replacing the two lines in func_accu.php (around line 275) converting the sunset/sunrise with:

    $weather_arr['sunrise'] = date($fc_time_format, strtotime($sunarr[0]) ); 
    $weather_arr['sunset']  = date($fc_time_format, strtotime($sunarr[1]) );

    Hopefully this will fix it. If it works I will integrate it into the next release.

    Thread Starter danielb1

    (@danielb1)

    Hi tuxlog.

    The suggested fix was successful. The times for sunset and sunrise are now correctly displayed. Thank you for the nice support.

    Best regards
    Daniel

    • This reply was modified 4 years, 6 months ago by danielb1.

    I have a similiar Problem, send already an email. Since we are in Wintertime the Time for Sunset and Sunrise are 1 hour in diffecerne, i use all like written here, the fix did not waork as it seems to be imnplemented in the newest version of wp forcast already.

    We are set in Canary Islands
    WP Timezone is set to Canary Islands and shows correctly

    Even if i set the Timezone to UTC +0 ist shows wrong times, when i go to accuwether and check manually it shows in accuweather Page the correct times for this. Any ideas?

    I found this lines:

    $weather_arr['sunrise'] = date($fc_time_format, strtotime($sunarr[0]) ); 
                $weather_arr['sunset']  = date($fc_time_format, strtotime($sunarr[1]) );

    For mee it loks like correct as you put it on here. But the last Update is 2 month ago and this “error” is just a bit longer active then 1 Month…

    • This reply was modified 4 years, 4 months ago by leogc.
    Thread Starter danielb1

    (@danielb1)

    Hi.

    After installing the latest update, everything works fine on our site now. Just as feedback to tuxlog.

    Best regards
    Daniel

    Unfortuneatly on my page not, all is on the newest version, WP, WP Gorcast, Timezone set correctly… hmmm

    Plugin Author tuxlog

    (@tuxlog)

    I turned out that the werong values came from accuweather to subtract one hour you can change accu_func.php:

    `$weather_arr[‘sunrise’] = date($fc_time_format, strtotime($sunarr[0]) );
    $weather_arr[‘sunset’] = date($fc_time_format, strtotime($sunarr[1]) );`

    to

    `$weather_arr[‘sunrise’] = date($fc_time_format, strtotime($sunarr[0]) – 3600 );
    $weather_arr[‘sunset’] = date($fc_time_format, strtotime($sunarr[1]) – 3600 );`

    This will do the trick.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Sunset and Sunrise off by two hours’ is closed to new replies.