Add timezone support to `date()` functions in Bases

Use case or problem

I am trying to create a basic Base table that shows all activity in the vault for a given day.
The catch is that I am using a created property in the front matter of the note and not the ctime attribute.

There are a few reasons for this, but they all boil down to ctime is not reliable or canonical.

For more detail on the why/current dataview based solution, see this thread: Bases - pass argument(s) to functions/filters? - #4 by dawni

Proposed solution

Ideally, the full moment.js API and or JS native Date() gets exposed.
Lacking that, a way to specify the parse/format string to be used when trying to turn a str into a Date would be enough:

# Assume that I have an ISO8601 (with seconds and TZ offset) formatted field in every note
#   with the key of `created` like this: 2025-08-21T14:09:46.000Z`
# created:
 - type: table
    name: Today's Activity (front_matter)
    filters:
      and:
        # Only show notes that have a created year that is identical to the year the filesystem says each note was created on.
        - date(created, "YYYY-MM-DDTHH:MM:SS.TZ").year == file.ctime.year

Current workaround (optional)

See the above linked thread. I use dataview’s “user scripts” to filter each note using some javascript:

// if input.filter_date is not defined, default to today
if (!input.filter_date) {
  input.filter_date = new Date().toISOString().split('T')[0];
}

dv.execute(`
  TABLE dateformat(file.cday, "yyyy-MM-dd") as "Created${input.exclude_self ? '(excluding self)' : ' (including self)'}"
  WHERE file.cday.year = date(${input.filter_date}).year
      AND file.cday.month = date(${input.filter_date}).month
      AND file.cday.day = date(${input.filter_date}).day
      ${input.exclude_self ? 'AND file.path != this.file.path' : ''}
  SORT file.cday desc
`);

Related feature requests (optional)

A quick search for timezone in the feature-request section w/ the bases tag didn’t return anything.

1 Like

It may be this:

Bear in mind that for the Obsidian datetime type property we currently don’t support, UTC zulu, nor time zone offsets, nor millisecond accuracy,.

1 Like

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