我搜索了这个问题的答案,但我发现的只是如何显示 12 小时制与 24 小时制时间格式,而不是何时显示。
我的问题与此类似:如何确定当前文化/语言环境是使用上午/下午还是 24 小时制?但我想知道我们是否具有与 Rails 中的 CurrentCulture 或 CultureInfo 类似的结构。
我相信使用语言环境应该是可能的,但我不知道该怎么做,或者是否有任何数据库明确提到哪些语言使用军事格式(24 小时)以及哪些使用 AM/PM 格式。
我搜索了这个问题的答案,但我发现的只是如何显示 12 小时制与 24 小时制时间格式,而不是何时显示。
我的问题与此类似:如何确定当前文化/语言环境是使用上午/下午还是 24 小时制?但我想知道我们是否具有与 Rails 中的 CurrentCulture 或 CultureInfo 类似的结构。
我相信使用语言环境应该是可能的,但我不知道该怎么做,或者是否有任何数据库明确提到哪些语言使用军事格式(24 小时)以及哪些使用 AM/PM 格式。
According to this wikipedia article, in most English-speaking regions, particularly the United States, the Philippines and the United Kingdom and its former colonies, the 12-hour clock is the predominant form of stating the time. Here is the relevant excerpt from the article:
In most English-speaking regions, particularly the United States, the Philippines and the United Kingdom and its former colonies, the 12-hour clock is the predominant form of stating > the time with the 24-hour clock used in contexts where unambiguity and accurate timekeeping > are important, such as for public transport schedules. Nonetheless, usage is inconsistent: in the UK, train timetables will typically use 24-hour time, but road signs indicating time > restrictions (e.g. on bus lanes) typically use 12-hour time.
Therefore, I suggested by Sergio in the comment, you may want to use geolocation to determine the appropriate default for the user and then expose the setting in the user interface to let the user fine tune this setting.