Enhancement: Custom date format with specific timezone #584

Closed
opened 2026-10-05 02:54:19 +02:00 by adam · 7 comments
Owner

Is your feature request related to a problem? Please describe.
Iam using hexo framework.

Hexo output time string when used format 2024-01-21T06:34:03.845Z is wrong hour. the result is 2024-01-21T16:54:43+07:00
image

i've tried changing config date format, but not working.
image
this also not work
image

Describe the solution you'd like
I want print custom date format like 2024-01-21T13:29:27+07:00

Discussion: https://github.com/estruyf/vscode-front-matter/discussions/735

Related forum:

**Is your feature request related to a problem? Please describe.** Iam using `hexo` framework. Hexo output time string when used format `2024-01-21T06:34:03.845Z` is wrong hour. the result is `2024-01-21T16:54:43+07:00` ![image](https://github.com/estruyf/vscode-front-matter/assets/12471057/b622002a-e9ce-4f98-8678-264a1fc1d9d9) i've tried changing config date format, but not working. ![image](https://github.com/estruyf/vscode-front-matter/assets/12471057/44fc23b5-4a91-4434-a924-e1ec0f00f28e) this also not work ![image](https://github.com/estruyf/vscode-front-matter/assets/12471057/2492ec3c-eb06-4073-b623-973fed974996) **Describe the solution you'd like** I want print custom date format like `2024-01-21T13:29:27+07:00` Discussion: https://github.com/estruyf/vscode-front-matter/discussions/735 Related forum: - https://stackoverflow.com/questions/19648688/moment-js-returning-wrong-date <!-- github-sync-id:2092446758 -->
adam closed this issue 2026-10-05 02:54:19 +02:00
Author
Owner

On the datetime field, you can set how to format your date.

For instance, in your case, you can set the following:

{
  "title": "Date",
  "name": "date",
  "type": "datetime",
  "dateFormat": "yyyy-MM-dd'T'HH:mm:ssxxx"
}

If you want to set it for all your date fields, you can use the frontMatter.taxonomy.dateFormat setting and use the same value like the dateFormat property.

On the `datetime` field, you can set how to format your date. For instance, in your case, you can set the following: ```json { "title": "Date", "name": "date", "type": "datetime", "dateFormat": "yyyy-MM-dd'T'HH:mm:ssxxx" } ``` If you want to set it for all your date fields, you can use the `frontMatter.taxonomy.dateFormat` setting and use the same value like the `dateFormat` property. <!-- github-comment-id:1903695680 -->
Author
Owner
yyyy-MM-dd'T'HH:mm:ssxxx

not work, the result still UTC ISO format.

image
result
image

How to set date format like 2024-01-21T16:54:43+07:00 ?
i've tried YYYY-MM-DD'T'HH:mm:ssZ not work

> ```json > yyyy-MM-dd'T'HH:mm:ssxxx > ``` not work, the result still UTC ISO format. ![image](https://github.com/estruyf/vscode-front-matter/assets/12471057/070d7de1-298a-440c-9ea5-edcea2ba3a98) result ![image](https://github.com/estruyf/vscode-front-matter/assets/12471057/be96aecf-e0bf-4d8f-9004-5aa8139fe303) How to set date format like `2024-01-21T16:54:43+07:00` ? i've tried `YYYY-MM-DD'T'HH:mm:ssZ` not work <!-- github-comment-id:1903874643 -->
Author
Owner

btw, in hexo _config.yml we can set timezone property like:

timezone: Asia/Jakarta

so, hexo will parse date with the given timezone or using config timezone. i think this caused inaccurate date output.

so, need custom formatting from frontmatter plugin to sync date with hexo.

btw, in hexo `_config.yml` we can set `timezone` property like: ```yaml timezone: Asia/Jakarta ``` so, hexo will parse date with the given timezone or using config timezone. i think this caused inaccurate date output. so, need custom formatting from frontmatter plugin to sync date with hexo. <!-- github-comment-id:1903890312 -->
Author
Owner

hey I found same format like hexo YYYY-MM-DD'T'HH:mm:ssZ.

the format is yyyy-MM-dd'T'HH:mm:ss.SSSXXX result 2024-01-25T22:03:38.825+07:00

how to output it like 2024-01-25T22:03:38+07:00 ?

hey I found same format like hexo `YYYY-MM-DD'T'HH:mm:ssZ`. the format is `yyyy-MM-dd'T'HH:mm:ss.SSSXXX` result `2024-01-25T22:03:38.825+07:00` how to output it like `2024-01-25T22:03:38+07:00` ? <!-- github-comment-id:1910394405 -->
Author
Owner

I fixed this issue with set custom date format to yyyy-MM-dd'T'HH:mm:ssXXX

here working config example for hexo:

{
  "$schema": "https://frontmatter.codes/frontmatter.schema.json",
  "frontMatter.content.autoUpdateDate": false,
  "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/"
}

result
image

I fixed this issue with set custom date format to `yyyy-MM-dd'T'HH:mm:ssXXX` here working config example for `hexo`: ```jsonc { "$schema": "https://frontmatter.codes/frontmatter.schema.json", "frontMatter.content.autoUpdateDate": false, "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/" } ``` result ![image](https://github.com/estruyf/vscode-front-matter/assets/12471057/3de81c0d-9924-4fea-8bc0-c9badf661f8f) <!-- github-comment-id:1910397913 -->
Author
Owner

On the datetime field, you can set how to format your date.

For instance, in your case, you can set the following:

{
  "title": "Date",
  "name": "date",
  "type": "datetime",
  "dateFormat": "yyyy-MM-dd'T'HH:mm:ssxxx"
}

If you want to set it for all your date fields, you can use the frontMatter.taxonomy.dateFormat setting and use the same value like the dateFormat property.

Thanks @dimaslanjaka I proposed it as well, might be that you've missed it. Glad you found it as well.

> On the `datetime` field, you can set how to format your date. > > For instance, in your case, you can set the following: > > ```json > { > "title": "Date", > "name": "date", > "type": "datetime", > "dateFormat": "yyyy-MM-dd'T'HH:mm:ssxxx" > } > ``` > > If you want to set it for all your date fields, you can use the `frontMatter.taxonomy.dateFormat` setting and use the same value like the `dateFormat` property. Thanks @dimaslanjaka I proposed it as well, might be that you've missed it. Glad you found it as well. <!-- github-comment-id:1910399838 -->
Author
Owner

@estruyf the auto update date when file is modified not follow the pattern, please fix. i mentioned this closed issue for reference.

@estruyf the auto update date when file is modified not follow the pattern, please fix. i mentioned this closed issue for reference. <!-- github-comment-id:2143641112 -->
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#584