跳转到内容

模板:Countdown:修订间差异

来自osm&bio
Magezeya留言 | 贡献
无编辑摘要
Magezeya留言 | 贡献
无编辑摘要
第2行: 第2行:
{{#if: {{{1|}}}
{{#if: {{{1|}}}
   | {{#if: {{{utc|}}}
   | {{#if: {{{utc|}}}
     | {{#if: {{{time|}}}
     | {{#if: {{#pos:{{{1}}}|:}}
       | {{#time: U | {{{1}}} {{{utc}}} }}
       | {{#time: U | {{{1}}} {{{utc}}} }}
       | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
       | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
     }}
     }}
     | {{#if: {{{time|}}}
     | {{#if: {{#pos:{{{1}}}|:}}
       | {{#time: U | {{{1}}} }}
       | {{#time: U | {{{1}}} }}
       | {{#time: U | {{{1}}} 00:00:00 }}
       | {{#time: U | {{{1}}} 00:00:00 }}
第13行: 第13行:
   {{#switch: {{{time|day}}}
   {{#switch: {{{time|day}}}
     | day = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}}
     | day = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}}
         | {{#if: {{{time|}}}
         | {{#if: {{#pos:{{{1}}}|:}}
           | {{#time: U | {{{1}}} {{{utc}}} }}
           | {{#time: U | {{{1}}} {{{utc}}} }}
           | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
           | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
         }}
         }}
         | {{#if: {{{time|}}}
         | {{#if: {{#pos:{{{1}}}|:}}
           | {{#time: U | {{{1}}} }}
           | {{#time: U | {{{1}}} }}
           | {{#time: U | {{{1}}} 00:00:00 }}
           | {{#time: U | {{{1}}} 00:00:00 }}
第23行: 第23行:
       }})) / 86400) }}
       }})) / 86400) }}
     | hour = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}}
     | hour = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}}
         | {{#if: {{{time|}}}
         | {{#if: {{#pos:{{{1}}}|:}}
           | {{#time: U | {{{1}}} {{{utc}}} }}
           | {{#time: U | {{{1}}} {{{utc}}} }}
           | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
           | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
         }}
         }}
         | {{#if: {{{time|}}}
         | {{#if: {{#pos:{{{1}}}|:}}
           | {{#time: U | {{{1}}} }}
           | {{#time: U | {{{1}}} }}
           | {{#time: U | {{{1}}} 00:00:00 }}
           | {{#time: U | {{{1}}} 00:00:00 }}
第33行: 第33行:
       }})) / 3600) }}
       }})) / 3600) }}
     | minute = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}}
     | minute = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}}
         | {{#if: {{{time|}}}
         | {{#if: {{#pos:{{{1}}}|:}}
           | {{#time: U | {{{1}}} {{{utc}}} }}
           | {{#time: U | {{{1}}} {{{utc}}} }}
           | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
           | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
         }}
         }}
         | {{#if: {{{time|}}}
         | {{#if: {{#pos:{{{1}}}|:}}
           | {{#time: U | {{{1}}} }}
           | {{#time: U | {{{1}}} }}
           | {{#time: U | {{{1}}} 00:00:00 }}
           | {{#time: U | {{{1}}} 00:00:00 }}
第43行: 第43行:
       }})) / 60) }}
       }})) / 60) }}
     | second = {{#expr: {{#time: U}} - ({{#if: {{{utc|}}}
     | second = {{#expr: {{#time: U}} - ({{#if: {{{utc|}}}
         | {{#if: {{{time|}}}
         | {{#if: {{#pos:{{{1}}}|:}}
           | {{#time: U | {{{1}}} {{{utc}}} }}
           | {{#time: U | {{{1}}} {{{utc}}} }}
           | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
           | {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }}
         }}
         }}
         | {{#if: {{{time|}}}
         | {{#if: {{#pos:{{{1}}}|:}}
           | {{#time: U | {{{1}}} }}
           | {{#time: U | {{{1}}} }}
           | {{#time: U | {{{1}}} 00:00:00 }}
           | {{#time: U | {{{1}}} 00:00:00 }}
第68行: 第68行:
=== 参数 ===
=== 参数 ===
; 1
; 1
: 目标日期 (YYYY-MM-DD格式)
: 目标日期 (YYYY-MM-DD或YYYY-MM-DD HH:MM:SS格式)
; utc
; utc
: 时区偏移 (可选,例如+8表示UTC+8)
: 时区偏移 (可选,例如+8表示UTC+8)
第80行: 第80行:
{{Countdown|2023-12-31|time=hour}} → 输出小时差
{{Countdown|2023-12-31|time=hour}} → 输出小时差
{{Countdown|2023-12-31 12:30:45|time=minute}} → 包含时间的分钟差
{{Countdown|2023-12-31 12:30:45|time=minute}} → 包含时间的分钟差
</pre>
[[Category:时间模板]]
</noinclude>
{{Countdown|2023-12-31}}  // 显示距离2023年12月31日还有/已过多少天
{{Countdown|2023-06-15}}  // 显示距离2023年6月15日还有/已过多少天
</pre>
</pre>


[[Category:时间模板]]
[[Category:时间模板]]
</noinclude>
</noinclude>

2025年8月21日 (四) 14:34的版本


倒计时模板

计算指定日期与当前时间的时间差,只输出数字结果。

使用方法

{{Countdown|目标日期|utc=时区|time=精度}}

参数

1
目标日期 (YYYY-MM-DD或YYYY-MM-DD HH:MM:SS格式)
utc
时区偏移 (可选,例如+8表示UTC+8)
time
精度 (可选,day-天/hour-小时/minute-分钟/second-秒,默认为day)

示例

{{Countdown|2023-12-31}} → 输出天数差
{{Countdown|2023-12-31|utc=+8}} → 使用UTC+8时区
{{Countdown|2023-12-31|time=hour}} → 输出小时差
{{Countdown|2023-12-31 12:30:45|time=minute}} → 包含时间的分钟差