EZ Inventory: Advanced Date and Time Variable Options
EZ Inventory has supported date and time variables in the filename/file paths, URLs, and filters for some time now. You can use the variables {{ YYYY }}, {{ MM }}, {{ DD }}, and {{ HH }}.
We've encountered a few cases where these aren't enough, however. So we've added a new variable called {{ current_datetime }} which extends this functionality further. With this new variable, you can include additional parameters to specify more advanced formatting, add or subtract days, and overwrite the timezone.
Below are a few use cases where this could come in handy:
- Your inventory feeds use a non-iSO 8601 date format such as something like "inventory_Jan202023.csv".
- Your FTP/SFTP server generates a file past midnight using the date from the previous day in the filename.
- Your FTP/SFTP server's timezone is different from your Shopify store's timezone (our app uses the store's timezone setting by default, this new option allows you to overwrite it when using date/time variables in the filename).
Here are some examples:
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 }}
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 }}
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 available format options, please click here. A list of valid timezone values can be found here.
Related Posts: