Hello team,
i want modify the post data format to YYYY-MM-DD HH:mm
Modifying in frontend javascript doesn’t seem reasonable
1.Can I use a theme to override this time?
2.how can i modify this in the email too(now it only display data)
All the date formats are available to customize along with other text. Check out this guide:
thanks for your reply, David
I saw this custom setting, but it seems that I don’t find it here.
I want to display the time format of all posts as absolute time. For example, the current my topic post ‘3h’ is displayed as ‘12 May 17:33’
do you know what is the best way for me to change all post data to the YYYY-MM-DD HH:mm format, even it post in some minutes
Ah I see!
In that case, you could try changing the “relative date duration” site setting.
relative_date_duration: Number of days after posting where post dates will be shown as relative (7d) instead of absolute (20 Feb).
So I think for your case, you would set it to 0
yes,
I have set it to 0, but it still doesn’t take effect now. Does it take some time or do I need to rake posts:rebake
like we do after change domain?
It should only need a page refresh to take effect. Has it made any difference at all? What do your post dates look like now?
Hmm, it seems like dates which are less than 23.5 hours ago are always shown as relative, regardless of that setting:
So, your change to the setting will have applied to posts more than 1 day old. But it doesn’t look like we currently have a way to change the behaviour of things which are less than a day old.
i see this file
discourse-main/app/assets/javascripts/discourse/app/components/post/meta-data/date.gjs
<template>
<div class="post-info post-date">
<a
class={{concatClass
"post-date"
(if (and @post.wiki @post.last_wiki_edit) "last-wiki-edit")
}}
href={{@post.shareUrl}}
title={{i18n "post.sr_date"}}
{{on "click" this.showShareModal}}
>
<RelativeDate @date={{this.date}} />
</a>
</div>
</template>
is this the correct template, can i change it by a theme component?
No, you cannot override .gjs templates, unfortunately (intended to improve and encourage stability of overrides)