Allow to select 24h time format #12157

Closed
opened 2025-11-02 10:00:32 -06:00 by GiteaMirror · 14 comments
Owner

Originally created by @ensc on GitHub (Dec 6, 2023).

Feature Description

gitea seems already to support the 24h time format but it appears that this is bound to the language settings.

Please add either

  • an option to select the time format explicitly, or
  • add more language variants (e.g. "english(uk)" -> 24h, "english(colonies)" -> 12h)

Time format and interface language are usually two different things. E.g. I prefer english language for technical content but 12h time format is completely unreadable for me.

Screenshots

No response

Originally created by @ensc on GitHub (Dec 6, 2023). ### Feature Description gitea seems already to support the 24h time format but it appears that this is bound to the language settings. Please add either - an option to select the time format explicitly, or - add more language variants (e.g. "english(uk)" -> 24h, "english(colonies)" -> 12h) Time format and interface language are usually two different things. E.g. I prefer english language for technical content but 12h time format is completely unreadable for me. ### Screenshots _No response_
GiteaMirror added the type/proposal label 2025-11-02 10:00:32 -06:00
Author
Owner

@silverwind commented on GitHub (Dec 12, 2023):

You mean the dates displayed on the web interface? We are using https://github.com/github/relative-time-element#relative-time-element and it does not seem to have an option for 24h format, so likely it would need to be contributed there first.

@silverwind commented on GitHub (Dec 12, 2023): You mean the dates displayed on the web interface? We are using https://github.com/github/relative-time-element#relative-time-element and it does not seem to have an option for 24h format, so likely it would need to be contributed there first.
Author
Owner

@ensc commented on GitHub (Dec 13, 2023):

@silverwind Problem is

<html lang="en-US" class="theme-auto">

When this would be lang="en-GB", then the 24h time format will be used. Having an additional "English (GB)" language option would probably the easiest solution.

@ensc commented on GitHub (Dec 13, 2023): @silverwind Problem is ```html <html lang="en-US" class="theme-auto"> ``` When this would be `lang="en-GB"`, then the 24h time format will be used. Having an additional "English (GB)" language option would probably the easiest solution.
Author
Owner

@silverwind commented on GitHub (Dec 13, 2023):

Hmm maybe a "en-GB" locale could be added as an alias to "en-US". I don't see us maintaining separate translations for it, too little gain.

@silverwind commented on GitHub (Dec 13, 2023): Hmm maybe a "en-GB" locale could be added as an alias to "en-US". I don't see us maintaining separate translations for it, too little gain.
Author
Owner

@inferenceus commented on GitHub (Mar 1, 2024):

I completely agree that 24-hour time format should be available. It's especially important in technical environments where correctness is required. I'd go further and say ISO 8601 (YYYY-MM-DD hh:mm:ss) should be available as the entire date and time string, regardless of UI language, which seems available in some conditions in the web UI I haven't been able to pin down yet.

@inferenceus commented on GitHub (Mar 1, 2024): I completely agree that 24-hour time format should be available. It's especially important in technical environments where correctness is required. I'd go further and say ISO 8601 (YYYY-MM-DD hh:mm:ss) should be available as the entire date and time string, regardless of UI language, which seems available in some conditions in the web UI I haven't been able to pin down yet.
Author
Owner

@wxiaoguang commented on GitHub (Mar 2, 2024):

I think there is a start for supporting this: Add global setting how timestamps should be rendered #28657

;;
;; The tense all timestamps should be rendered in. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) and `mixed`.
;; `mixed` means most timestamps are rendered in relative time (i.e. 2 days ago).
;PREFERRED_TIMESTAMP_TENSE = mixed

More improvements could be done based on that approach (if there could be found more).

ps: it is only a instance-wide config, not a user-level config .....

@wxiaoguang commented on GitHub (Mar 2, 2024): I think there is a start for supporting this: Add global setting how timestamps should be rendered #28657 ``` ;; ;; The tense all timestamps should be rendered in. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) and `mixed`. ;; `mixed` means most timestamps are rendered in relative time (i.e. 2 days ago). ;PREFERRED_TIMESTAMP_TENSE = mixed ``` More improvements could be done based on that approach (if there could be found more). ps: it is only a instance-wide config, not a user-level config .....
Author
Owner

@inferenceus commented on GitHub (Mar 2, 2024):

@wxiaoguang

I think there is a start for supporting this: Add global setting how timestamps should be rendered #28657

;;
;; The tense all timestamps should be rendered in. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) and `mixed`.
;; `mixed` means most timestamps are rendered in relative time (i.e. 2 days ago).
;PREFERRED_TIMESTAMP_TENSE = mixed

More improvements could be done based on that approach (if there could be found more).

I agree with this. It looks like a great way to implement it.

ps: it is only a instance-wide config, not a user-level config .....

That's fine by me. I'd do it server-wide, anyway.

@inferenceus commented on GitHub (Mar 2, 2024): @wxiaoguang > I think there is a start for supporting this: Add global setting how timestamps should be rendered #28657 > > ``` > ;; > ;; The tense all timestamps should be rendered in. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) and `mixed`. > ;; `mixed` means most timestamps are rendered in relative time (i.e. 2 days ago). > ;PREFERRED_TIMESTAMP_TENSE = mixed > ``` > > More improvements could be done based on that approach (if there could be found more). I agree with this. It looks like a great way to implement it. > ps: it is only a instance-wide config, not a user-level config ..... That's fine by me. I'd do it server-wide, anyway.
Author
Owner

@silverwind commented on GitHub (Mar 7, 2024):

I don't like a instance-wide setting, it forces the admin's preference onto users, it's disrespectful to users. There are way to detect 24h preference in JS. Also <relative-time> docs says:

Dates are displayed before months, and a 24-hour clock is used, according to the user's browser settings.

So maybe it's already supported and you just need to fix your OS/browser locale settings?

@silverwind commented on GitHub (Mar 7, 2024): I don't like a instance-wide setting, it forces the admin's preference onto users, it's disrespectful to users. There are way to [detect 24h preference in JS](https://stackoverflow.com/questions/60740996). Also `<relative-time>` [docs](https://github.com/github/relative-time-element?tab=readme-ov-file#relative-time-element) says: > Dates are displayed before months, and a 24-hour clock is used, according to the user's browser settings. So maybe it's already supported and you just need to fix your OS/browser locale settings?
Author
Owner

@silverwind commented on GitHub (Mar 7, 2024):

I checked locally and it seems it's not working for me. OS has 24h format:

image

Gitea displays 12h:

image
@silverwind commented on GitHub (Mar 7, 2024): I checked locally and it seems it's not working for me. OS has 24h format: <img width="263" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/8048d3a1-4557-4380-9aaf-421d586e4221"> Gitea displays 12h: <img width="252" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/ff631481-91eb-4f74-9577-f5da2257bfaf">
Author
Owner

@denyskon commented on GitHub (Mar 7, 2024):

image
Works for me

@denyskon commented on GitHub (Mar 7, 2024): ![image](https://github.com/go-gitea/gitea/assets/47871822/ce402dd6-4322-4151-b06b-4e7205e84733) Works for me
Author
Owner

@denyskon commented on GitHub (Mar 7, 2024):

Oh it really depends on your Gitea language, with English I also get 12h format

@denyskon commented on GitHub (Mar 7, 2024): Oh it really depends on your Gitea language, with English I also get 12h format
Author
Owner

@silverwind commented on GitHub (Mar 7, 2024):

I found the fix, PR incoming...

@silverwind commented on GitHub (Mar 7, 2024): I found the fix, PR incoming...
Author
Owner

@silverwind commented on GitHub (Mar 7, 2024):

https://github.com/go-gitea/gitea/pull/29651

@silverwind commented on GitHub (Mar 7, 2024): https://github.com/go-gitea/gitea/pull/29651
Author
Owner

@inferenceus commented on GitHub (Mar 8, 2024):

@silverwind

I don't like a instance-wide setting, it forces the admin's preference onto users, it's disrespectful to users.

Some people like instance-wide enforcement, and there are good reasons for it, such as standards compliance which is very important, such as ISO 8601 in this case. It's still a choice, either way. We currently don't have a choice at all. Well, at least until #29651 .

@inferenceus commented on GitHub (Mar 8, 2024): @silverwind > I don't like a instance-wide setting, it forces the admin's preference onto users, it's disrespectful to users. Some people like instance-wide enforcement, and there are good reasons for it, such as standards compliance which is very important, such as ISO 8601 in this case. It's still a choice, either way. We currently don't have a choice *at all*. Well, at least until #29651 .
Author
Owner

@silverwind commented on GitHub (Mar 8, 2024):

Locale settings can be forced to users if you control their browser or OS and that will work for many websites not just gitea.

@silverwind commented on GitHub (Mar 8, 2024): Locale settings can be forced to users if you control their browser or OS and that will work for many websites not just gitea.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12157