Ecommerce Shopify WordPress Discussion

Javascript new Date(); returns 1970-01-01 in Shopify Function

I am working on a Shopify Function in which today's date is compared to another date. When I run new Date(); to get today's date, it returns "1970-01-01" I know this is epoch time, but the issue I am having is everyone says new Date(); is supposed to return today's date, but it isn't working for me. Is this an issue with how Shopify extensions handle dateTime parsing, or is there some other way I am supposed to get today's date.
Ok, so I found a solution for this that is specifically related to Shopify. I am creating an extension for Shopify using the Storefront API. To get the current date (dateTime functionality has unfortunately not been added as of writing this answer) you need to add the following to your .graphql query: shop { localTime { date } } Here is a link to the documentation:

January 27, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.