# 如果本地时间是午夜，则日期时间会丢弃时间

**URL:** https://meta.discourse.org/t/date-time-drops-time-if-it-is-locally-midnight/204803
**Category:** Feature
**Created:** [2021年九月29日 20:48 UTC](https://meta.discourse.org/t/date-time-drops-time-if-it-is-locally-midnight/204803 "2021-09-29T20:48:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![cogdog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cogdog/32/116536_2.png) [@cogdog](https://meta.discourse.org/u/cogdog)
#### Post date: [2021年九月29日 20:48 UTC](https://meta.discourse.org/t/date-time-drops-time-if-it-is-locally-midnight/204803/1 "2021-09-29T20:48:12Z")

</div>

日期/时间功能对我们国际组织按当地时间列出活动极为有用。我们非常喜欢它，尤其是无需让用户去第三方时区时钟查询。

我今天注意到，当某事在当地时间午夜发生时，显示的时间戳会消失，仅显示星期几。我原以为是我的代码有误，但这似乎就是其工作机制。能否让解析为午夜的时间戳像下拉菜单那样显示“12:00 AM”？

 ![Time at midnight not displayed](https://global.discourse-cdn.com/meta/original/3X/b/b/bb85f7de1a467a33b1ea323b955914d463de7715.jpeg)

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2021年九月30日 10:11 UTC](https://meta.discourse.org/t/date-time-drops-time-if-it-is-locally-midnight/204803/4 "2021-09-30T10:11:08Z")

</div>

这实际上是多年前根据他人的反馈特意制作的：[FIX: removes time from date in calendar range at midnight (#10751) · jjaffeux/discourse@2b254f4 · GitHub](https://github.com/jjaffeux/discourse/commit/2b254f4305e)

一种解决方案是禁用日历逻辑：

```plaintext
[date=2021-10-01 time=00:00:00 timezone="Europe/Paris" calendar=false]

```

这对您来说可以接受吗？

---

<div class="post-metadata">

### Author: ![cogdog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cogdog/32/116536_2.png) [@cogdog](https://meta.discourse.org/u/cogdog)
#### Post date: [2021年九月30日 14:29 UTC](https://meta.discourse.org/t/date-time-drops-time-if-it-is-locally-midnight/204803/5 "2021-09-30T14:29:06Z")

</div>

谢谢 Joffrey，看起来这能行……它随后会移除“今天、明天”作为显示选项（这不是问题），这个设置还有其他影响吗？

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2021年九月30日 15:18 UTC](https://meta.discourse.org/t/date-time-drops-time-if-it-is-locally-midnight/204803/6 "2021-09-30T15:18:10Z")

</div>

是的，它移除了当日期临近时尝试显示星期名称，或像“明天/昨天”这类花哨内容的功能。
