DateTime with offset can't be formatted with date.format()

Steps to reproduce

  1. Add an offset to a note property with the Date & Time type
    • date: 2017-05-15T10:00:00-08:00
  2. Add a formula to a base and apply the format() function to the property
    • date.format("DD-MM-YYYY")

Did you follow the troubleshooting guide? [Y/N]

Yes.
Tested in sandbox mode.

Expected result

The date should be parsed and formatted correctly.

Actual result

Formula throws error Cannot find function "format" on type String

Environment

Obsidian version: v1.9.10
Installer version: v1.8.10
Operating system: Windows 10 Pro 10.0.19045
Login status: not logged in
Language: fr
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: off
Plugins installed: 0
Plugins enabled: 0

Additional information

The time offset property is displayed correctly when added as a regular column.

thanks

I ran into the same issue, and hope this is a simple fix. In the meantime, I’ve found this ugly-as-sin formula as a workaround:

date(this.date.toString().split("T", 1).join("")).date()

(For those keeping score at home, this works by taking the date (with offset), converting it to a string, splitting that into a list, rejoining the list to make a (new) string (without the offset), and then converting that string back to a date.)

2 Likes

Interesting, I’ll try to tweak to make it work on my end while waiting for a fix.

That’s how I made it work
date(date.toString().split("-",3).join("-")).format('DD MMMM YYYY, HH:mm')
It won’t work if I have dates with a + offset.

1 Like

This is also a temporary workaround which takes the time into account:

date(some_field.slice(0, 19))

(The T is happily ignored by the date() function)

1 Like

will be fixed 1.9.12 1.10.x. No ETAs

1 Like

My timestamp property looks like this: 2025-08-21T12:34:56+07:00

So presumably this incoming change means that for a “creation time” Bases column formula currently as:

date(timestamp.split("+", 1).join("")).format("HH:mm:ss")

will be able to be simplified to:

date(timestamp).format("HH:mm:ss")

Ideally even just the following if a date with an offset suffix is recognised / formatted as a date type:

timestamp.format("HH:mm:ss")

It would be neat if milliseconds were also supported: 2025-08-21T12:34:56.789+10:00

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