{
  "workflow": {
    "id": 1744,
    "name": "Working with dates and times",
    "views": 85381,
    "recentViews": 0,
    "totalViews": 85381,
    "createdAt": "2022-07-06T12:24:08.722Z",
    "description": "**Task:**\nHandle dates and times in your workflow\n\n**Why:**\nDate and time formats can be hard to work with, we have 2 main ways of doing that with n8n that cover all the main needs\n\n**Main use cases:**\n - Change date format\n - Set custom dates (incl. now and today)\n - Date math",
    "workflow": {
      "nodes": [
        {
          "name": "On clicking 'execute'",
          "type": "n8n-nodes-base.manualTrigger",
          "position": [
            1140,
            780
          ],
          "parameters": {},
          "typeVersion": 1
        },
        {
          "name": "Note",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            1480,
            760
          ],
          "parameters": {
            "width": 560,
            "height": 400,
            "content": "## 2. Advanced way: Using Expressions\nIn this `Set` node, we set dates using [Luxon expressions](https://docs.n8n.io/code-examples/expressions/luxon/) for the following formats:\n\nNow - `{{$now}}`\nCurrent time with seconds - `{{$now.toLocaleString(DateTime.TIME_WITH_SECONDS)}}`\nToday - `{{$today}}`\nTomorrow - `{{$today.plus({days: 1})}}`\nOne hour ago - `{{$now.minus({hours: 1})}}`\nWeekday name - `{{$today.weekdayLong}}`\n\n"
          },
          "typeVersion": 1
        },
        {
          "name": "Note3",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            660,
            780
          ],
          "parameters": {
            "width": 420,
            "height": 100,
            "content": "### Click the `Execute Workflow` button and double click on the nodes to see the input and output items."
          },
          "typeVersion": 1
        },
        {
          "name": "12 Hours from now",
          "type": "n8n-nodes-base.dateTime",
          "position": [
            1520,
            580
          ],
          "parameters": {
            "value": "={{$now}}",
            "action": "calculate",
            "options": {},
            "duration": 12,
            "timeUnit": "hours"
          },
          "typeVersion": 1
        },
        {
          "name": "Note1",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            1480,
            400
          ],
          "parameters": {
            "width": 560,
            "height": 340,
            "content": "## 1. Simple Way: Using the Date & Time node\nThere are two actions available within the `Date & Time` node:\n1. Calculating a date - adding/substracting minutes,hours, days, etc.\n2. Formatting a date\n\n"
          },
          "typeVersion": 1
        },
        {
          "name": "Note4",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            1980,
            860
          ],
          "parameters": {
            "width": 480,
            "height": 320,
            "content": "### 2.1 Working with an existing time string\nAs items pass between nodes, n8n saves dates as ISO strings. This means that in order to work with the data as a date again, we need to convert it back using `DateTime.fromISO('yyyy-mm-dd')`\n. Once doing that, we are able to apply date and time function again such as : `{{DateTime.fromISO($json[\"Now\"]).toFormat('yyyy LLL dd')}}`"
          },
          "typeVersion": 1
        },
        {
          "name": "Set times",
          "type": "n8n-nodes-base.set",
          "position": [
            1520,
            1020
          ],
          "parameters": {
            "values": {
              "string": [
                {
                  "name": "Now",
                  "value": "={{$now}}"
                },
                {
                  "name": "Current time with seconds",
                  "value": "={{$now.toLocaleString(DateTime.TIME_WITH_SECONDS)}}"
                },
                {
                  "name": "Today",
                  "value": "={{$today}}"
                },
                {
                  "name": "Tomorrow",
                  "value": "={{$today.plus({days: 1})}}"
                },
                {
                  "name": "One hour from now",
                  "value": "={{$now.minus({hours: 1})}}"
                },
                {
                  "name": "Weekday",
                  "value": "={{$today.weekdayLong}}"
                }
              ]
            },
            "options": {}
          },
          "typeVersion": 1
        },
        {
          "name": "Edit times",
          "type": "n8n-nodes-base.set",
          "position": [
            2080,
            1020
          ],
          "parameters": {
            "values": {
              "string": [
                {
                  "name": "Current time",
                  "value": "={{DateTime.fromISO($json[\"Now\"])}}"
                },
                {
                  "name": "Current time formatted",
                  "value": "={{DateTime.fromISO($json[\"Now\"]).toFormat('yyyy LLL dd')}}"
                }
              ]
            },
            "options": {},
            "keepOnlySet": true
          },
          "typeVersion": 1
        },
        {
          "name": "Format - MMMM DD YY",
          "type": "n8n-nodes-base.dateTime",
          "position": [
            1760,
            580
          ],
          "parameters": {
            "value": "={{$now}}",
            "options": {},
            "toFormat": "MMMM DD YYYY"
          },
          "typeVersion": 1
        }
      ],
      "connections": {
        "Set times": {
          "main": [
            [
              {
                "node": "Edit times",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "12 Hours from now": {
          "main": [
            [
              {
                "node": "Format - MMMM DD YY",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "On clicking 'execute'": {
          "main": [
            [
              {
                "node": "Set times",
                "type": "main",
                "index": 0
              },
              {
                "node": "12 Hours from now",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    },
    "lastUpdatedBy": 1,
    "workflowInfo": null,
    "status": "published",
    "readyToDemo": null,
    "user": {
      "name": "Jonathan",
      "username": "jon-n8n",
      "bio": null,
      "verified": true,
      "links": [],
      "avatar": "https://gravatar.com/avatar/5240094f838126182ceefb50ca4a3cf75cc7dc0808efd4b9920d792e41bfc45e?r=pg&d=retro&size=200"
    },
    "nodes": [
      {
        "id": 38,
        "icon": "fa:pen",
        "name": "n8n-nodes-base.set",
        "codex": {
          "data": {
            "alias": [
              "Set",
              "JS",
              "JSON",
              "Filter",
              "Transform",
              "Map"
            ],
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/learn-to-automate-your-factorys-incident-reporting-a-step-by-step-guide/",
                  "icon": "🏭",
                  "label": "Learn to Automate Your Factory's Incident Reporting: A Step by Step Guide"
                },
                {
                  "url": "https://n8n.io/blog/2021-the-year-to-automate-the-new-you-with-n8n/",
                  "icon": "☀️",
                  "label": "2021: The Year to Automate the New You with n8n"
                },
                {
                  "url": "https://n8n.io/blog/automatically-pulling-and-visualizing-data-with-n8n/",
                  "icon": "📈",
                  "label": "Automatically pulling and visualizing data with n8n"
                },
                {
                  "url": "https://n8n.io/blog/database-monitoring-and-alerting-with-n8n/",
                  "icon": "📡",
                  "label": "Database Monitoring and Alerting with n8n"
                },
                {
                  "url": "https://n8n.io/blog/automatically-adding-expense-receipts-to-google-sheets-with-telegram-mindee-twilio-and-n8n/",
                  "icon": "🧾",
                  "label": "Automatically Adding Expense Receipts to Google Sheets with Telegram, Mindee, Twilio, and n8n"
                },
                {
                  "url": "https://n8n.io/blog/no-code-ecommerce-workflow-automations/",
                  "icon": "store",
                  "label": "6 e-commerce workflows to power up your Shopify s"
                },
                {
                  "url": "https://n8n.io/blog/how-to-build-a-low-code-self-hosted-url-shortener/",
                  "icon": "🔗",
                  "label": "How to build a low-code, self-hosted URL shortener in 3 steps"
                },
                {
                  "url": "https://n8n.io/blog/automate-your-data-processing-pipeline-in-9-steps-with-n8n/",
                  "icon": "⚙️",
                  "label": "Automate your data processing pipeline in 9 steps"
                },
                {
                  "url": "https://n8n.io/blog/how-to-get-started-with-crm-automation-and-no-code-workflow-ideas/",
                  "icon": "👥",
                  "label": "How to get started with CRM automation (with 3 no-code workflow ideas"
                },
                {
                  "url": "https://n8n.io/blog/5-tasks-you-can-automate-with-notion-api/",
                  "icon": "⚡️",
                  "label": "5 tasks you can automate with the new Notion API "
                },
                {
                  "url": "https://n8n.io/blog/automate-google-apps-for-productivity/",
                  "icon": "💡",
                  "label": "15 Google apps you can combine and automate to increase productivity"
                },
                {
                  "url": "https://n8n.io/blog/how-uproc-scraped-a-multi-page-website-with-a-low-code-workflow/",
                  "icon": " 🕸️",
                  "label": "How uProc scraped a multi-page website with a low-code workflow"
                },
                {
                  "url": "https://n8n.io/blog/building-an-expense-tracking-app-in-10-minutes/",
                  "icon": "📱",
                  "label": "Building an expense tracking app in 10 minutes"
                },
                {
                  "url": "https://n8n.io/blog/the-ultimate-guide-to-automate-your-video-collaboration-with-whereby-mattermost-and-n8n/",
                  "icon": "📹",
                  "label": "The ultimate guide to automate your video collaboration with Whereby, Mattermost, and n8n"
                },
                {
                  "url": "https://n8n.io/blog/5-workflow-automations-for-mattermost-that-we-love-at-n8n/",
                  "icon": "🤖",
                  "label": "5 workflow automations for Mattermost that we love at n8n"
                },
                {
                  "url": "https://n8n.io/blog/learn-to-build-powerful-api-endpoints-using-webhooks/",
                  "icon": "🧰",
                  "label": "Learn to Build Powerful API Endpoints Using Webhooks"
                },
                {
                  "url": "https://n8n.io/blog/how-a-membership-development-manager-automates-his-work-and-investments/",
                  "icon": "📈",
                  "label": "How a Membership Development Manager automates his work and investments"
                },
                {
                  "url": "https://n8n.io/blog/a-low-code-bitcoin-ticker-built-with-questdb-and-n8n-io/",
                  "icon": "📈",
                  "label": "A low-code bitcoin ticker built with QuestDB and n8n.io"
                },
                {
                  "url": "https://n8n.io/blog/how-to-set-up-a-ci-cd-pipeline-with-no-code/",
                  "icon": "🎡",
                  "label": "How to set up a no-code CI/CD pipeline with GitHub and TravisCI"
                },
                {
                  "url": "https://n8n.io/blog/benefits-of-automation-and-n8n-an-interview-with-hubspots-hugh-durkin/",
                  "icon": "🎖",
                  "label": "Benefits of automation and n8n: An interview with HubSpot's Hugh Durkin"
                },
                {
                  "url": "https://n8n.io/blog/how-goomer-automated-their-operations-with-over-200-n8n-workflows/",
                  "icon": "🛵",
                  "label": "How Goomer automated their operations with over 200 n8n workflows"
                },
                {
                  "url": "https://n8n.io/blog/aws-workflow-automation/",
                  "label": "7 no-code workflow automations for Amazon Web Services"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.set/"
                }
              ]
            },
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Data Transformation"
              ]
            }
          }
        },
        "group": "[\"input\"]",
        "defaults": {
          "name": "Edit Fields"
        },
        "iconData": {
          "icon": "pen",
          "type": "icon"
        },
        "displayName": "Edit Fields (Set)",
        "typeVersion": 3,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 221,
        "icon": "fa:clock",
        "name": "n8n-nodes-base.dateTime",
        "codex": {
          "data": {
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/no-code-ecommerce-workflow-automations/",
                  "icon": "store",
                  "label": "6 e-commerce workflows to power up your Shopify s"
                },
                {
                  "url": "https://n8n.io/blog/how-to-get-started-with-crm-automation-and-no-code-workflow-ideas/",
                  "icon": "👥",
                  "label": "How to get started with CRM automation (with 3 no-code workflow ideas"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.datetime/"
                }
              ]
            },
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Data Transformation"
              ]
            }
          }
        },
        "group": "[\"transform\"]",
        "defaults": {
          "name": "Date & Time",
          "color": "#408000"
        },
        "iconData": {
          "icon": "clock",
          "type": "icon"
        },
        "displayName": "Date & Time",
        "typeVersion": 2,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 565,
        "icon": "fa:sticky-note",
        "name": "n8n-nodes-base.stickyNote",
        "codex": {
          "data": {
            "alias": [
              "Comments",
              "Notes",
              "Sticky"
            ],
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Helpers"
              ]
            }
          }
        },
        "group": "[\"input\"]",
        "defaults": {
          "name": "Sticky Note",
          "color": "#FFD233"
        },
        "iconData": {
          "icon": "sticky-note",
          "type": "icon"
        },
        "displayName": "Sticky Note",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      }
    ],
    "categories": [
      {
        "id": 5,
        "name": "Engineering"
      }
    ],
    "image": []
  }
}