Auto update date when markdown modified not follow isModifiedDate date pattern on GitHub Codespaces #642

Closed
opened 2026-10-05 02:58:11 +02:00 by adam · 9 comments
Owner

Describe the bug
Auto update modified date not follow configuration isModifiedDate

To Reproduce
Steps to reproduce the behavior:

  1. Setup frontmatter.json
{
  "$schema": "https://frontmatter.codes/frontmatter.schema.json",
  "frontMatter.content.autoUpdateDate": true,
  "frontMatter.preview.host": "http://localhost:4000",
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": false,
      "fields": [
        {
          "title": "Title",
          "name": "title",
          "type": "string"
        },
        {
          "title": "Description",
          "name": "description",
          "type": "string"
        },
        {
          "title": "Publishing date",
          "name": "date",
          "type": "datetime",
          "default": "{{now}}",
          "isPublishDate": true,
          "dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX"
        },
        {
          "title": "Thumbnail",
          "name": "thumbnail",
          "type": "image"
        },
        {
          "title": "Is in draft",
          "name": "draft",
          "type": "boolean"
        },
        {
          "title": "Tags",
          "name": "tags",
          "type": "tags"
        },
        {
          "title": "Categories",
          "name": "categories",
          "type": "categories"
        },
        {
          "title": "updated",
          "name": "updated",
          "type": "datetime",
          "default": "{{now}}",
          "isModifiedDate": true,
          "dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX"
        },
        {
          "name": "permalink",
          "editable": true,
          "type": "slug"
        },
        {
          "title": "Author",
          "name": "author",
          "type": "divider"
        }
      ]
    }
  ],
  "frontMatter.framework.id": "hexo",
  "frontMatter.content.publicFolder": "hexo:post_asset_folder",
  "frontMatter.content.pageFolders": [
    {
      "path": "[[workspace]]/posts",
      "title": "Source Posts"
    }
  ],
  "frontMatter.site.baseURL": "https://www.webmanajemen.com/"
}
  1. Open markdown frontmatter file format
  2. Edit any text then save

Expected behavior
The modified date should follow format this config

{
  "title": "updated",
  "name": "updated",
  "type": "datetime",
  "default": "{{now}}",
  "isModifiedDate": true,
  "dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX"
}

looks like 2024-06-01T17:14:14+07:00 - hexo date format issue

Screenshots

look at updated: 2024-06-02T00:02:57Z, it totally wrong and hexo will produce invalid date format.

image

Desktop (please complete the following information):

  • OS: Ubuntu (Codespace), Windows 10 (PC)
  • Browser: Firefox latest
  • Version: idk
**Describe the bug** Auto update modified date not follow configuration `isModifiedDate` **To Reproduce** Steps to reproduce the behavior: 1. Setup `frontmatter.json` ```jsonc { "$schema": "https://frontmatter.codes/frontmatter.schema.json", "frontMatter.content.autoUpdateDate": true, "frontMatter.preview.host": "http://localhost:4000", "frontMatter.taxonomy.contentTypes": [ { "name": "default", "pageBundle": false, "fields": [ { "title": "Title", "name": "title", "type": "string" }, { "title": "Description", "name": "description", "type": "string" }, { "title": "Publishing date", "name": "date", "type": "datetime", "default": "{{now}}", "isPublishDate": true, "dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX" }, { "title": "Thumbnail", "name": "thumbnail", "type": "image" }, { "title": "Is in draft", "name": "draft", "type": "boolean" }, { "title": "Tags", "name": "tags", "type": "tags" }, { "title": "Categories", "name": "categories", "type": "categories" }, { "title": "updated", "name": "updated", "type": "datetime", "default": "{{now}}", "isModifiedDate": true, "dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX" }, { "name": "permalink", "editable": true, "type": "slug" }, { "title": "Author", "name": "author", "type": "divider" } ] } ], "frontMatter.framework.id": "hexo", "frontMatter.content.publicFolder": "hexo:post_asset_folder", "frontMatter.content.pageFolders": [ { "path": "[[workspace]]/posts", "title": "Source Posts" } ], "frontMatter.site.baseURL": "https://www.webmanajemen.com/" } ``` 2. Open markdown frontmatter file format 3. Edit any text then save **Expected behavior** The modified date should follow format this config ```jsonc { "title": "updated", "name": "updated", "type": "datetime", "default": "{{now}}", "isModifiedDate": true, "dateFormat": "yyyy-MM-dd'T'HH:mm:ssXXX" } ``` looks like `2024-06-01T17:14:14+07:00` - [hexo date format issue](https://github.com/estruyf/vscode-front-matter/issues/736) **Screenshots** look at `updated: 2024-06-02T00:02:57Z`, it totally wrong and `hexo` will produce invalid date format. ![image](https://github.com/estruyf/vscode-front-matter/assets/12471057/66ab1d12-9418-40d8-978b-f781e0f69781) **Desktop (please complete the following information):** - OS: Ubuntu (Codespace), Windows 10 (PC) - Browser: Firefox latest - Version: idk <!-- github-sync-id:2329399174 -->
adam closed this issue 2026-10-05 02:58:11 +02:00
Author
Owner

That is weird, as the date formatting uses the dateFormat setting in the code. Which version of FM are you using? I cannot reproduce it with your configuration in the stable or beta versions.

https://github.com/estruyf/vscode-front-matter/assets/2900833/9ab1faf5-954b-40af-b692-34d1cae44116

That is weird, as the date formatting uses the `dateFormat` setting in the code. Which version of FM are you using? I cannot reproduce it with your configuration in the stable or beta versions. https://github.com/estruyf/vscode-front-matter/assets/2900833/9ab1faf5-954b-40af-b692-34d1cae44116 <!-- github-comment-id:2151835107 -->
Author
Owner

That is weird, as the date formatting uses the dateFormat setting in the code. Which version of FM are you using? I cannot reproduce it with your configuration in the stable or beta versions.

version latest stable. here my screen record - https://drive.google.com/file/d/1n5mbJC9ihCSM1jSxaGMGUdyn3I0FASxY/view?usp=sharing

> That is weird, as the date formatting uses the `dateFormat` setting in the code. Which version of FM are you using? I cannot reproduce it with your configuration in the stable or beta versions. version latest stable. here my screen record - https://drive.google.com/file/d/1n5mbJC9ihCSM1jSxaGMGUdyn3I0FASxY/view?usp=sharing <!-- github-comment-id:2153603571 -->
Author
Owner

@estruyf here my full project https://github.com/dimaslanjaka/source-posts/tree/master (branch master and dont forget git submodule update -i -r)
You can check which parts cause bugs.

@estruyf here my full project https://github.com/dimaslanjaka/source-posts/tree/master (branch master and dont forget `git submodule update -i -r`) You can check which parts cause bugs. <!-- github-comment-id:2153613084 -->
Author
Owner

Interesting. I cannot reproduce it locally; it is only in a codespace. Will have to find a way how I can test it 🙃

Interesting. I cannot reproduce it locally; it is only in a codespace. Will have to find a way how I can test it 🙃 <!-- github-comment-id:2154242030 -->
Author
Owner

🤦‍♂️ - there is nothing wrong; it is just that the Codespaces clock is set to UTC. That is why the XXX results in Z.

So the yyyy-MM-dd'T'HH:mm:ssXXX format on a Codespace is formatted to: 2024-06-07T08:02:21Z.

You can also see this in the date-fns its format method documentation: https://date-fns.org/v3.6.0/docs/format - XXX results in: -08:00, +05:30, Z

Also checked with extra logging in the output:

image

Here you can see that the dateFormat value is used for formatting your date.

🤦‍♂️ - there is nothing wrong; it is just that the Codespaces clock is set to UTC. That is why the `XXX` results in `Z`. So the `yyyy-MM-dd'T'HH:mm:ssXXX` format on a Codespace is formatted to: `2024-06-07T08:02:21Z`. You can also see this in the `date-fns` its `format` method documentation: https://date-fns.org/v3.6.0/docs/format - `XXX` results in: -08:00, +05:30, Z Also checked with extra logging in the output: ![image](https://github.com/estruyf/vscode-front-matter/assets/2900833/bdedb341-a7df-4df3-a389-22a1b227e420) Here you can see that the `dateFormat` value is used for formatting your date. <!-- github-comment-id:2154317555 -->
Author
Owner

🤦‍♂️ - there is nothing wrong; it is just that the Codespaces clock is set to UTC. That is why the XXX results in Z.

So the yyyy-MM-dd'T'HH:mm:ssXXX format on a Codespace is formatted to: 2024-06-07T08:02:21Z.

You can also see this in the date-fns its format method documentation: https://date-fns.org/v3.6.0/docs/format - XXX results in: -08:00, +05:30, Z

Also checked with extra logging in the output:

image

Here you can see that the dateFormat value is used for formatting your date.

when I tap Update NOW working (auto update post date disabled state)

image

only the auto update modified post wrong format

> 🤦‍♂️ - there is nothing wrong; it is just that the Codespaces clock is set to UTC. That is why the `XXX` results in `Z`. > > So the `yyyy-MM-dd'T'HH:mm:ssXXX` format on a Codespace is formatted to: `2024-06-07T08:02:21Z`. > > You can also see this in the `date-fns` its `format` method documentation: https://date-fns.org/v3.6.0/docs/format - `XXX` results in: -08:00, +05:30, Z > > Also checked with extra logging in the output: > > ![image](https://private-user-images.githubusercontent.com/2900833/337578851-bdedb341-a7df-4df3-a389-22a1b227e420.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgyMzM3OTMsIm5iZiI6MTcxODIzMzQ5MywicGF0aCI6Ii8yOTAwODMzLzMzNzU3ODg1MS1iZGVkYjM0MS1hN2RmLTRkZjMtYTM4OS0yMmExYjIyN2U0MjAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MTJUMjMwNDUzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9N2JkMWI5M2FhZTYxYmJiOTY3NzRiMGJjYzUyZGM5YTExZTc2ZmRjNGI4ZjNhNDlkZjUwZjFiYThkMzBlOGQ5ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.etY_K0UdPcuDKUFRam2tm-WuLq4md6_ITMJSyE5sUEE) > > Here you can see that the `dateFormat` value is used for formatting your date. when I tap **Update NOW** working (auto update post date disabled state) ![image](https://github.com/estruyf/vscode-front-matter/assets/12471057/2c7e7747-6430-4077-b425-4959fa47f17e) only the auto update modified post wrong format <!-- github-comment-id:2164039698 -->
Author
Owner

When you click on the now button, your browser triggers it, invoking it from the client side, which results in a correct value on your end.

When the automated date update gets invoked, it is on the "backend", which runs on the codespace itself. Because the codespace runs on UTC, it returns a different value.

When you click on the `now` button, your browser triggers it, invoking it from the client side, which results in a correct value on your end. When the automated date update gets invoked, it is on the "backend", which runs on the codespace itself. Because the codespace runs on UTC, it returns a different value. <!-- github-comment-id:2165069904 -->
Author
Owner

@dimaslanjaka I found a solution and it is to set the timezone for your GH Codespace. I just wrote a blog post about it on how you can set the timezone for your codespace: https://www.eliostruyf.com/set-timezone-github-codespaces/

@dimaslanjaka I found a solution and it is to set the timezone for your GH Codespace. I just wrote a blog post about it on how you can set the timezone for your codespace: https://www.eliostruyf.com/set-timezone-github-codespaces/ <!-- github-comment-id:2165516065 -->
Author
Owner

@dimaslanjaka I found a solution and it is to set the timezone for your GH Codespace. I just wrote a blog post about it on how you can set the timezone for your codespace: https://www.eliostruyf.com/set-timezone-github-codespaces/

nice working.

image

here my step to get working (might useful for someone else):

# timezone.sh
#!/bin/bash

# Set timezone to Asia/Jakarta
sudo ln -sf /usr/share/zoneinfo/Asia/Jakarta /etc/localtime
sudo timedatectl set-timezone Asia/Jakarta
echo "Timezone set to $(date)"
  • include the timezone script in .bashrc or .zshrc
# your other .bashrc or .zshrc configs

# set timezone
if [ -f ~/dotfiles/timezone.sh ]; then
    chmod +x ~/dotfiles/timezone.sh
    ~/dotfiles/timezone.sh
elif [ -f ./timezone.sh ]; then
    chmod +x ./timezone.sh
    ./timezone.sh
fi
  • now rebuild your codespaces
  • after finish, open terminal execute command date
> @dimaslanjaka I found a solution and it is to set the timezone for your GH Codespace. I just wrote a blog post about it on how you can set the timezone for your codespace: https://www.eliostruyf.com/set-timezone-github-codespaces/ nice working. ![image](https://github.com/estruyf/vscode-front-matter/assets/12471057/0bcbd6c9-214d-4c68-b69a-fa3bd8b63b0c) here my step to get working (might useful for someone else): - set timezone in `.devcontainer/devcontainer.json` => https://github.com/dimaslanjaka/source-posts/blob/d67d837dfc29f57b5f2e43cc9d264486a98c605e/.devcontainer/devcontainer.json#L1-L5 - add timezone change script in dotfiles repository ```bash # timezone.sh #!/bin/bash # Set timezone to Asia/Jakarta sudo ln -sf /usr/share/zoneinfo/Asia/Jakarta /etc/localtime sudo timedatectl set-timezone Asia/Jakarta echo "Timezone set to $(date)" ``` - include the timezone script in `.bashrc` or `.zshrc` ```bash # your other .bashrc or .zshrc configs # set timezone if [ -f ~/dotfiles/timezone.sh ]; then chmod +x ~/dotfiles/timezone.sh ~/dotfiles/timezone.sh elif [ -f ./timezone.sh ]; then chmod +x ./timezone.sh ./timezone.sh fi ``` - now rebuild your codespaces - after finish, open terminal execute command `date` <!-- github-comment-id:2166938052 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#642