Using Date and Time Variables in the Filename

In the "Export Profile" settings of EZ Exporter, you can use certain date and time variables to dynamically assign values based on the current date and time (using the timezone of the Shopify store).

For example, if you'd like to name the exported file something like shopify_orders_20190227_090522.csv, you can use the pattern below in the "Filename pattern" field:

  • shopify_orders_{{ year }}{{ month }}{{ day }}_{{ hour }}{{ minute }}{{ second }}.csv

Below is a list of available date/time variables you can use:

  • {{ timestamp }} (e.g. 20190327_090522)
  • {{ date }} (e.g. 20190327)
  • {{ time }} (e.g. 090522)
  • {{ year }} (e.g. 2019)
  • {{ month }} (e.g. 03)
  • {{ day }} (e.g. 27)
  • {{ hour }} (e.g. 09)
  • {{ minute }} (e.g. 45)
  • {{ second }} (e.g. 58)

These variables can also be used in the email subject and message.  When using our Google Sheets integration, you can use these variables in the "Sheet name" as well.

Advanced Formatting

We also offer more advanced date/time formatting via the {{ current_datetime }} variable, where you have much more options on the date/time format and also the ability to add or subtract days.

Datetime Format String

Format the current date as M-D-YY without zero-padding (e.g. 1-2-23):

{{ current_datetime|format:%-m-%-d-%y }}

Format the current date as AbbrevMonth DD, YYYY (e.g. Jan 02, 2023)

{{ current_datetime|format:%b %d, %Y }}

Include the timestamp all the way to the microsecond (e.g. 20230124_183045_951531).  This would make it very very unlikely to have filename conflicts if you have multiple exports scheduled to run at the same time with the same filename pattern and uploading to the same folder.

{{ current_datetime|format:%Y%m%d_%H%M%S_%f }}

Here's a reference of available format strings:

Code Meaning Example
%a Weekday as locale’s abbreviated name. Mon
%A Weekday as locale’s full name. Monday
%w Weekday as a decimal number, where 0 is Sunday and 6 is Saturday. 1
%d Day of the month as a zero-padded decimal number. 30
%b Month as locale’s abbreviated name. Sep
%B Month as locale’s full name. September
%m Month as a zero-padded decimal number. 09
%y Year without century as a zero-padded decimal number. 13
%Y Year with century as a decimal number. 2013
%H Hour (24-hour clock) as a zero-padded decimal number. 07
%I Hour (12-hour clock) as a zero-padded decimal number. 07
%p Locale’s equivalent of either AM or PM. AM
%M Minute as a zero-padded decimal number. 06
%S Second as a zero-padded decimal number. 05
%f Microsecond as a decimal number, zero-padded on the left. 000000
%z UTC offset in the form +HHMM or -HHMM (empty string if the the object is naive).  
%Z Time zone name (empty string if the object is naive).  
%j Day of the year as a zero-padded decimal number. 273
%U Week number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. 39
%W Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0. 39
%c Locale’s appropriate date and time representation. Mon Sep 30 07:06:05 2013
%x Locale’s appropriate date representation. 09/30/13
%X Locale’s appropriate time representation. 07:06:05
%% A literal '%' character. %

Adding or Subtracting Days

Format the current date as YYYY-MM-DD, then add 2 days.

{{ current_datetime|format:%Y-%m-%d|add_days:2 }}

Format the current date as YYYY-MM-DD, then subtract 1 day.

{{ current_datetime|format:%Y-%m-%d|add_days:-1 }}

Overwriting Timezone

By default, the timezone is set based on the Shopify store's timezone setting.  If the system receiving and processing the file requires the date/time in the filename to be at a different timezone, you can overwrite it using the set_timezone parameter.

Format the current date as YYYY-MM-DD_HH in America/New_York timezone:

{{ current_datetime|format:%Y-%m-%d_%H|set_timezone:America/New_York }}

For a list of valid timezone values, please click here.


Related Articles:


App: EZ Exporter

Tags: advanced features