@@ -296,12 +296,20 @@ function railtimetable_today($attr) {
296296
297297 $ stations = explode (', ' , $ attr ['stations ' ]);
298298 $ times = array ();
299- $ now = date ("Y-m-d " );
299+ $ timezone = new \DateTimeZone (get_option ('timezone_string ' ));
300+ $ now = new DateTime ();
301+ $ now ->setTimezone ($ timezone );
302+ $ now = $ now ->format ("Y-m-d " );
300303 $ datetime = new DateTime ('tomorrow ' );
304+ $ datetime ->setTimezone ($ timezone );
301305 $ tomorrow = $ datetime ->format ('Y-m-d ' );
302306
303- // If it's after 17:00 then visitors probably want tomorrows train times.
304- if (date ('H ' ) > 20 ) {
307+ // If it's after 18:00 then visitors probably want tomorrows train times.
308+ $ hour = new DateTime ();
309+ $ hour ->setTimezone ($ timezone );
310+ $ hour = $ hour ->format ('H ' );
311+
312+ if ($ hour > 18 ) {
305313 $ now = $ tomorrow ;
306314 }
307315
@@ -509,9 +517,15 @@ function railtimetable_events($attr) {
509517 global $ wpdb ;
510518 railtimetable_setlangage ();
511519 $ now = date ("Y-m-d " );
512-
513- // If it's after 19:00 then visitors probably want the next event.
514- if (date ('H ' ) > 19 ) {
520+ $ now = new DateTime ();
521+ $ now ->setTimezone ($ timezone );
522+ $ now = $ now ->format ("Y-m-d " );
523+ $ hour = new DateTime ();
524+ $ hour ->setTimezone ($ timezone );
525+ $ hour = $ hour ->format ('H ' );
526+
527+ // If it's after 18:00 then visitors probably want the next event.
528+ if ($ hour > 18 ) {
515529 $ datetime = new DateTime ('tomorrow ' );
516530 $ now = $ datetime ->format ('Y-m-d ' );
517531 }
0 commit comments