# 如何在 Jalali（非 Gregorian）中显示所有日期和时间

**URL:** <https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098>\
**Category:** Support\
**Created:** [2024年十二月7日 12:28 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098 "2024-12-07T12:28:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![serkhelesheyi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/serkhelesheyi/32/497726_2.png) [@serkhelesheyi](https://meta.discourse.org/u/serkhelesheyi)\
**Post date:** [2024年十二月7日 12:28 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/1 "2024-12-07T12:28:08Z")

</div>

我已在 Ubuntu 上本地安装了 Discourse，不在 Docker 中。如何将论坛中的日期转换为 **Jalali** 日期？  
谢谢

---

<div class="post-metadata">

**Author:** ![Andro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andro/32/173721_2.png) [@Andro](https://meta.discourse.org/u/Andro)\
**Post date:** [2024年十二月8日 02:12 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/2 "2024-12-08T02:12:22Z")

</div>

这有帮助吗？

> <https://askubuntu.com/questions/470438/how-can-i-change-calender-to-persian-calender-like-in-kde>

我不知道 Discourse 是否会考虑如此具体的本地化。抱歉！

---

<div class="post-metadata">

**Author:** ![Andro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andro/32/173721_2.png) [@Andro](https://meta.discourse.org/u/Andro)\
**Post date:** [2024年十二月8日 02:14 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/3 "2024-12-08T02:14:58Z")

</div>

我刚刚发现 Discourse 支持 locale 模块。所以比我更懂的人能够指导你，我对此很有信心。

---

<div class="post-metadata">

**Author:** ![serkhelesheyi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/serkhelesheyi/32/497726_2.png) [@serkhelesheyi](https://meta.discourse.org/u/serkhelesheyi)\
**Post date:** [2024年十二月8日 05:21 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/5 "2024-12-08T05:21:46Z")

</div>

> [@Andro](#):
>
> This would help?

非常感谢您的回答。  
不幸的是，没有。  
我的意思是，如何将论坛中显示的帖子的日期和其他日期从公历转换为 Jalali。

---

<div class="post-metadata">

**Author:** ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)\
**Post date:** [2024年十二月8日 12:01 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/6 "2024-12-08T12:01:17Z")

</div>

您可以在管理员设置界面将默认区域设置为波斯语/法尔西语。这或许可行。

似乎没有办法让单个 Discourse 用户设置他们偏好的区域设置——我猜他们的浏览器会在每次请求时发送该信息。我看到 Chrome 提供了包括波斯语在内的语言设置。也许这会起作用。

---

<div class="post-metadata">

**Author:** ![serkhelesheyi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/serkhelesheyi/32/497726_2.png) [@serkhelesheyi](https://meta.discourse.org/u/serkhelesheyi)\
**Post date:** [2024年十二月8日 20:21 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/7 "2024-12-08T20:21:20Z")

</div>

> [@Ed\_S](#):
>
> 您可以在管理员设置界面中将默认区域设置为波斯语/法西语。这也许可行。

非常感谢您的回答。  
但不幸的是，不行。

---

<div class="post-metadata">

**Author:** ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)\
**Post date:** [2024年十二月8日 21:15 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/8 "2024-12-08T21:15:17Z")

</div>

啊，抱歉，这没有帮助。我认为您可能需要某种插件。

---

<div class="post-metadata">

**Author:** ![Andro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/andro/32/173721_2.png) [@Andro](https://meta.discourse.org/u/Andro)\
**Post date:** [2024年十二月9日 08:35 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/9 "2024-12-09T08:35:18Z")

</div>

所以 @serkhelesheyi 你到底想要什么确切的区域设置？从你的 OP 来看并不明显。

如果它不存在，我认为区域设置模块是可插入的，有人可以为你编写一个。

另外，顺便说一句，你会发现这里支持人员强烈建议通过 Docker 安装 Discourse，并且通常不愿意帮助非 Docker 安装，因为任何数量的事情都可能与标准设置不同。只是顺便说一句。

---

<div class="post-metadata">

**Author:** ![serkhelesheyi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/serkhelesheyi/32/497726_2.png) [@serkhelesheyi](https://meta.discourse.org/u/serkhelesheyi)\
**Post date:** [2024年十二月9日 10:50 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/10 "2024-12-09T10:50:35Z")

</div>

将区域设置为伊朗/波斯语，唯一的区别是它以波斯字母显示公历月份。我想做的是显示 Jalali 日历的月份，而不是公历的月份。

---

<div class="post-metadata">

**Author:** ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)\
**Post date:** [2024年十二月9日 13:30 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/11 "2024-12-09T13:30:58Z")

</div>

如果您有预算，可以在 marketplace 上寻求帮助。

> **[Marketplace](https://meta.discourse.org/c/marketplace/14)**
>
> This is your hub for all Discourse-related commerce: jobs, gigs, plugins, themes, hosting, and more.

---

<div class="post-metadata">

**Author:** ![serkhelesheyi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/serkhelesheyi/32/497726_2.png) [@serkhelesheyi](https://meta.discourse.org/u/serkhelesheyi)\
**Post date:** [2024年十二月9日 14:18 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/12 "2024-12-09T14:18:17Z")

</div>

不，很遗憾我没有预算，但非常感谢您介绍市场。

---

<div class="post-metadata">

**Author:** ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)\
**Post date:** [2024年十二月9日 14:45 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/13 "2024-12-09T14:45:02Z")

</div>

我在命令行中尝试了以下操作：

```plaintext
# locale-gen fa_IR.UTF-8

```

现在似乎有了些东西：

```plaintext
# date
Mon Dec 9 15:43:50 CET 2024
# env LC_TIME=fa_IR.utf8 date
<U+202B>دوشنبه ۰۹ دسامبر ۲۴، ساعت ۱۵:۴۳:۵۱ (CET)<U+202C>

```

但我无法确定它是否有用，因为我没有这方面的语言技能。（我怀疑这和你看到的一样，公历日期被逐字翻译了）

---

<div class="post-metadata">

**Author:** ![serkhelesheyi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/serkhelesheyi/32/497726_2.png) [@serkhelesheyi](https://meta.discourse.org/u/serkhelesheyi)\
**Post date:** [2024年十二月9日 14:59 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/14 "2024-12-09T14:59:07Z")

</div>

非常感谢  
不，我不想这样。这只是显示了波斯字母的月份名称。我想要的是实际显示 Jalali 月份。  
例如，在你提到的文本中，“دسامبر”一词被提及为一个月份，在波斯语中发音为 December（十二月）。我想要显示的是 Jalali 日历的第九个月（我的意思是“Azar”（آذر））。

---

<div class="post-metadata">

**Author:** ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)\
**Post date:** [2024年十二月9日 15:07 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/15 "2024-12-09T15:07:11Z")

</div>

确实如此。在我看来，在最低的 Unix 系统级别上没有什么可以帮助您。因此，您确实需要应用程序级别的某些东西——某种用于 Discourse 的包、主题或插件，它被用于所有有日期的地方。

这些功能当然[存在](https://github.com/you-dont-need/You-Dont-Need-Momentjs)于 JavaScript 中——（moment.js、day.js、date-fns）——但如果它们尚未提供，将它们整合到 Discourse 中是一项技术任务，超出了我自己的能力。

编辑：我看了一下，似乎 moment.js 已经可用，所以这可能并不那么困难。

---

<div class="post-metadata">

**Author:** ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)\
**Post date:** [2024年十二月9日 15:13 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/16 "2024-12-09T15:13:13Z")

</div>

这里有一些相关信息：

> [@How to properly display jalali dates for Persian language](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/20?u=moin):
>
> It looks like there are moment.js plugins for Hijri and Jalali calenders: [Moment.js | Docs](https://momentjs.com/docs/#/plugins/jalaali/) To see how easy it’s to use, I cloned the Hijri plugin into vendor folder and changed the dates formats in client.ar.yml according to the plugin documentation and I got it to display Hijri dates in a few places: (July 2017 is in 1438 Hijri year) I’m guessing it didn’t display Hijri dates in all places because those were using different core methods for displaying dates and might need to be twe…

---

<div class="post-metadata">

**Author:** ![serkhelesheyi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/serkhelesheyi/32/497726_2.png) [@serkhelesheyi](https://meta.discourse.org/u/serkhelesheyi)\
**Post date:** [2024年十二月9日 15:24 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/17 "2024-12-09T15:24:36Z")

</div>

是的。解决方案是使用 moment.js，但我不知道如何使用它，我需要有人从头到尾指导我。

---

<div class="post-metadata">

**Author:** ![serkhelesheyi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/serkhelesheyi/32/497726_2.png) [@serkhelesheyi](https://meta.discourse.org/u/serkhelesheyi)\
**Post date:** [2024年十二月9日 15:27 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/18 "2024-12-09T15:27:50Z")

</div>

非常感谢您的指导。  
我之前看过这个帖子，但我的问题是我不知道如何操作，需要有人向我解释所有步骤。

---

<div class="post-metadata">

**Author:** ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)\
**Post date:** [2024年十二月9日 15:42 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/19 "2024-12-09T15:42:48Z")

</div>

我注意到之前有一个类似的要求：  
[将 Discourse 的视图层中的公历日期转换为 Jalali 日期的转换器](https://meta.discourse.org/t/converter-to-change-gregorian-date-to-jalali-on-view-layer-of-discourse/61671)

但这个更有希望：  
[使用 moment-jalaali.js 时加载仪表板报告出错](https://meta.discourse.org/t/error-in-loading-dashboard-reports-when-using-moment-jalaali-js/168909)

它又链接回这个更早的：  
[如何为波斯语正确显示 Jalali 日期](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157)  
（编辑：哎呀，我看到这个之前已经被链接过了）

我建议更改此主题的标题，也许是：  
如何以 Jalali（而非公历）显示所有日期和时间

（我认为需要的是纯粹的显示——数据库中的实际时间戳不会改变。这些时间戳将是自 1970 年以来的秒数）

---

<div class="post-metadata">

**Author:** ![serkhelesheyi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/serkhelesheyi/32/497726_2.png) [@serkhelesheyi](https://meta.discourse.org/u/serkhelesheyi)\
**Post date:** [2024年十二月9日 16:21 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/20 "2024-12-09T16:21:00Z")

</div>

非常感谢您的建议和指导。

---

<div class="post-metadata">

**Author:** ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)\
**Post date:** [2024年十二月10日 16:13 UTC](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098/22 "2024-12-10T16:13:39Z")

</div>

> [@Ed\_S](#):
>
> 我建议更改此主题的标题，也许是：  
> 如何显示所有日期和时间为 Jalali（而非公历）

我已按建议更改了标题。谢谢！

移除了 unsupported-install 标签 - 此问题与该事实无关。不过，我建议 @serkhelesheyi 使用官方安装说明进行安装，以避免遇到其他可能遇到的问题。

> [@Osama](#):
>
> 总的来说，我认为 Hijri 支持应该通过插件实现，并且使用一个 **新的** 单独的阿拉伯语区域设置，以便人们可以选择 Hijri 或 Gregorian。

看起来 @osama 在那里回答了这个问题。目前没有支持的方法可以显示 Jalali（而非公历）的日期和时间，但如果有人有时间和兴趣，可以将其实现为插件。

[下一頁](https://meta.discourse.org/t/how-to-display-all-dates-and-times-in-jalali-not-gregorian/341098.md?page=2)
