• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Merchant Labs

Helping online merchants succeed is what we do best!

  • About
  • Contact
  • My Account

JavaScript / June 21, 2020

Javascript date format with timezone that also works in Safari

Recently I was working on a website where I needed to add a countdown timer. Rather than going with a bloated library I chose to implement it myself.

Everything worked great until I checked it on Safari. I got a NaN for all the date data. After doing a few google searches I found it was a common issue. Luckily I found a very simple solution here; use an ISO 8601 date format.

Basically the issue was that I was missing a semicolon in the timezone.

This did not work: 2020-06-22T00:00:00.000-0800
But this did work: 2020-06-22T00:00:00.000-08:00

The format breaks down to this (date)T(time)+/-(timezone offset)

Date is year-month-day followed by T for time, then the time as hour:minute:seconds:milliseconds

Filed Under: JavaScript Tagged With: Coding, Javascript

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Footer

Shopify Partner

Let Merchant Labs, with over 15 years experience in ecommerce, help you SUCCEED online! From …

Read More about Shopify Development Services

  • Twitter
  • YouTube

Ajax-Cart Coming Soon

What is Ajax-cart for Shopify? Ajax-cart for Shopify is a big project to bring some of the most wanted features to the Shopify cart page. This page is also known as the basket screen. Its …

more about Ajax-Cart for Shopify

Tags

Apps Script Coding Documentation Javascript MySQL PHP Shopify Liquid

Contact Us

Merchant Labs
Los Angeles, California

P: 424-236-0372
E: [email protected]

Proud Partners For

Copyright © 2025 · Digital Pro on Genesis Framework · WordPress · Log in