Closed dimaslanjaka closed 8 months ago
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.
yyyy-MM-dd'T'HH:mm:ssxxx
not work, the result still UTC ISO format.
result
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
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.
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
?
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
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 thedateFormat
property.
Thanks @dimaslanjaka I proposed it as well, might be that you've missed it. Glad you found it as well.
@estruyf the auto update date when file is modified not follow the pattern, please fix. i mentioned this closed issue for reference.
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 is2024-01-21T16:54:43+07:00
i've tried changing config date format, but not working. this also not work
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: