Bug Description
The EventDetails block render callback uses strtotime() + date_i18n() to format dates. Because WordPress sets PHP's default timezone to UTC but date_i18n() formats in the site timezone (America/Chicago), date-only strings (no time component) get shifted backward by the timezone offset.
Affected Locations
| File |
Line |
Code |
inc/Blocks/EventDetails/render.php |
129 |
date_i18n( get_option('date_format'), strtotime($start_datetime) ) |
inc/Blocks/EventDetails/render.php |
131 |
date_i18n( get_option('time_format'), strtotime($start_datetime) ) |
inc/Blocks/EventDetails/render.php |
139 |
date_i18n( get_option('date_format'), strtotime($occ_date) ) |
inc/Blocks/Calendar/templates/results-counter.php |
22 |
date_i18n( 'M j', strtotime($page_start_date) ) |
inc/Blocks/Calendar/templates/results-counter.php |
23 |
date_i18n( 'M j', strtotime($page_end_date) ) |
How It Breaks
WordPress's wp-settings.php calls date_default_timezone_set('UTC'). So:
strtotime("2026-04-06") // → midnight UTC: 2026-04-06 00:00:00 UTC
date_i18n('date_format', ...) // → formats in CDT (UTC-5): 2026-04-05 19:00
// Result: April 5 (Sunday) instead of April 6 (Monday) — shifted BACK 1 day
For date+time strings like "2026-04-06 18:00": 18:00 UTC → 13:00 CDT, still April 6. Works only because 18:00 - 5h = 13:00 doesn't cross midnight.
For early morning events like "2026-04-06 02:00": 02:00 UTC → 21:00 CDT previous day → wrong date.
Fix
Replace strtotime() + date_i18n() with timezone-aware DateTime:
// Instead of:
date_i18n( $format, strtotime( $date_string ) );
// Use:
$dt = new DateTime( $date_string, wp_timezone() );
echo $dt->format( $format );
Or use wp_date() which handles timezone correctly:
echo wp_date( $format, strtotime( $date_string . ' 00:00:00' ), wp_timezone() );
Severity
This is a latent bug — it doesn't affect the current Monday Night Funk Jam issue (which is caused by #1) but will cause incorrect date display for:
- Occurrence dates in the single-event view
- Any event with start time before 5:00 AM CDT / 6:00 AM EDT
- The calendar results counter pagination dates
Bug Description
The
EventDetailsblock render callback usesstrtotime()+date_i18n()to format dates. Because WordPress sets PHP's default timezone to UTC butdate_i18n()formats in the site timezone (America/Chicago), date-only strings (no time component) get shifted backward by the timezone offset.Affected Locations
inc/Blocks/EventDetails/render.phpdate_i18n( get_option('date_format'), strtotime($start_datetime) )inc/Blocks/EventDetails/render.phpdate_i18n( get_option('time_format'), strtotime($start_datetime) )inc/Blocks/EventDetails/render.phpdate_i18n( get_option('date_format'), strtotime($occ_date) )inc/Blocks/Calendar/templates/results-counter.phpdate_i18n( 'M j', strtotime($page_start_date) )inc/Blocks/Calendar/templates/results-counter.phpdate_i18n( 'M j', strtotime($page_end_date) )How It Breaks
WordPress's
wp-settings.phpcallsdate_default_timezone_set('UTC'). So:For date+time strings like
"2026-04-06 18:00": 18:00 UTC → 13:00 CDT, still April 6. Works only because 18:00 - 5h = 13:00 doesn't cross midnight.For early morning events like
"2026-04-06 02:00": 02:00 UTC → 21:00 CDT previous day → wrong date.Fix
Replace
strtotime()+date_i18n()with timezone-awareDateTime:Or use
wp_date()which handles timezone correctly:Severity
This is a latent bug — it doesn't affect the current Monday Night Funk Jam issue (which is caused by #1) but will cause incorrect date display for: