I tried adding the script and viewed again on my iPhone14 device but still has that error.
What iOS phone are you using?
A Shopify store owner reports a countdown timer displaying “NaN” error on iOS devices while functioning correctly on Android and desktop browsers. Screenshots confirm the cross-platform inconsistency.
Troubleshooting attempts:
DOMContentLoaded event listener didn’t resolve the issueRoot cause identified:
The issue stems from date string parsing inconsistencies across browsers. The code uses new Date('{{ section.settings.custom_liquid }} 00:00:00'), but iOS Safari parses date strings differently than other browsers.
Proposed solution:
Reformat the date string to the ISO 8601 standard (yyyy-mm-ddThh:mm:ss.sssZ), which is universally recognized across all browsers. Adding “.000” to the time format should resolve the parsing issue and eliminate the NaN error on iOS devices.
Additional note: There’s a mismatch between using countdown as a class in HTML while attempting to retrieve it by ID in the script.
I tried adding the script and viewed again on my iPhone14 device but still has that error.
What iOS phone are you using?