Timezone strangeness sending ISO date strings to Notion

Hi,

I’m passing Apple health data to a Notion database and dates are showing up +1 hour.

Part of Notion node input:
Screenshot 2023-09-14 at 21.13.37

Settings:

Part of Notion node output:

1 Hr ahead in Notion:

Timezone in docker-compose.yml:

Timezone in Notion:

Any ideas on why / how n8n seems to be adding an hour to the ISO strings would be much appreciated.

Cheers

Information on your n8n setup

  • n8n version: 1.5.1

I would be interested to see this aswell. I have had all sorts of strange things happen when dealing with time into Notion.

Hi @Tony_McHugh :wave: That’s strange :thinking: Could you share your workflow and some sample data in JSON format for testing? :eyes:

Hi @EmeraldHerald. Sure, here’s the workflow:

And some data (I think):

[
  {
    "active_energy": 52.3,
    "basal_energy_burned": 968.03,
    "body_fat_percentage": 20.72,
    "body_mass_index": 23.39,
    "carbohydrates": 0,
    "dietary_energy": 4715.37,
    "dietary_sugar": 0,
    "fiber": 0,
    "protein": 0,
    "resting_heart_rate": 48,
    "inBed": 8.5,
    "core": 3.95,
    "sleepEnd": "2023-09-15 11:06:00 +0100",
    "asleep": 0,
    "rem": 2.17,
    "deep": 0.52,
    "inBedStart": "2023-09-15 01:30:00 +0100",
    "awake": 0.05,
    "inBedEnd": "2023-09-15 10:00:12 +0100",
    "sleepStart": "2023-09-15 01:30:00 +0100",
    "step_count": 2000,
    "total_fat": 0
  }
]

Let me know, cheers

Hi @Tony_McHugh :wave: Thanks for that! When I tested I was able to get the correct timezone, so this is interesting :thinking:

Could you try using an expression such as {{ $now.setZone("Europe/London").toISO() }} and seeing if that fixes this?

Hi @EmeraldHerald,

Thanks for this.

Replacing one of my fields in the final Update "DATA" node with your suggestion does indeed put the expected date and time into Notion but I’m unsure how to use this information to fix my issue. Any ideas?

Cheers

Hi @Tony_McHugh :wave: I’m not too sure if this is what you’re looking for, but take a peek at this post:

If you’ve already a proper ISO stamp, you wouldn’t even have to use .fromFormat() but could go with the much simpler DateTime.fromISO($json.myFieldName) instead :+1:

Hi @EmeraldHerald,

Can’t seem to get any of those to work. I think the issue is that my data string is off the form “2023-09-18 10:00:07 +0100” i.e. no “T” and has spaces. Weird though because Notion still accepts it, albeit after interpreting it incorrectly…

Should I try to convert my string to the proper ISO format or work with Notions apparent data structure:

"property_in_bed_start": { "start": "2023-09-18T09:05:00.000+01:00", "end": null, "time_zone": null },

and try to change the time zone there. I’ve tried inputing a data structure like this into the expression field but it also fails… very confused right now

@EmeraldHerald sorry never mind, it seems I was leaving out “ZZZ” in the format string for DateTime.fromFormat function. This did the trick:

{{ DateTime.fromFormat($json.inBedStart, "yyyy-MM-dd HH:mm:ss ZZZ") }}

Cheers

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.