模板:Countdown:修订间差异
外观
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
<includeonly> | <includeonly> | ||
{{#if: {{{1|}}} | {{#if: {{{1|}}} | ||
| {{# | | {{#if: {{{utc|}}} | ||
{{# | | {{#if: {{{time|}}} | ||
| {{#time: U | {{{1}}} {{{utc}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }} | |||
}} | }} | ||
| {{#if: {{{time|}}} | |||
| {{#time: U | {{{1}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 }} | |||
}} | |||
}} | |||
{{#switch: {{{time|day}}} | |||
| day = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}} | |||
| {{#if: {{{time|}}} | |||
| {{#time: U | {{{1}}} {{{utc}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }} | |||
}} | |||
| {{#if: {{{time|}}} | |||
| {{#time: U | {{{1}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 }} | |||
}} | |||
}})) / 86400) }} | |||
| hour = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}} | |||
| {{#if: {{{time|}}} | |||
| {{#time: U | {{{1}}} {{{utc}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }} | |||
}} | |||
| {{#if: {{{time|}}} | |||
| {{#time: U | {{{1}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 }} | |||
}} | |||
}})) / 3600) }} | |||
| minute = {{#expr: floor(({{#time: U}} - ({{#if: {{{utc|}}} | |||
| {{#if: {{{time|}}} | |||
| {{#time: U | {{{1}}} {{{utc}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }} | |||
}} | |||
| {{#if: {{{time|}}} | |||
| {{#time: U | {{{1}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 }} | |||
}} | |||
}})) / 60) }} | |||
| second = {{#expr: {{#time: U}} - ({{#if: {{{utc|}}} | |||
| {{#if: {{{time|}}} | |||
| {{#time: U | {{{1}}} {{{utc}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 {{{utc}}} }} | |||
}} | |||
| {{#if: {{{time|}}} | |||
| {{#time: U | {{{1}}} }} | |||
| {{#time: U | {{{1}}} 00:00:00 }} | |||
}} | |||
}}) }} | |||
}} | |||
| 错误:未提供日期参数 | | 错误:未提供日期参数 | ||
}} | }} | ||
| 第14行: | 第58行: | ||
<noinclude> | <noinclude> | ||
== | == 倒计时模板 == | ||
计算指定日期与当前时间的时间差,只输出数字结果。 | |||
=== 使用方法 === | === 使用方法 === | ||
<pre> | <pre> | ||
{{Countdown|目标日期}} | {{Countdown|目标日期|utc=时区|time=精度}} | ||
</pre> | </pre> | ||
=== 参数 === | |||
; 1 | |||
: 目标日期 (YYYY-MM-DD格式) | |||
; utc | |||
: 时区偏移 (可选,例如+8表示UTC+8) | |||
; time | |||
: 精度 (可选,day-天/hour-小时/minute-分钟/second-秒,默认为day) | |||
=== 示例 === | === 示例 === | ||
<pre> | <pre> | ||
{{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}} → 包含时间的分钟差 | |||
</pre> | |||
[[Category:时间模板]] | |||
</noinclude> | |||
{{Countdown|2023-12-31}} // 显示距离2023年12月31日还有/已过多少天 | {{Countdown|2023-12-31}} // 显示距离2023年12月31日还有/已过多少天 | ||
{{Countdown|2023-06-15}} // 显示距离2023年6月15日还有/已过多少天 | {{Countdown|2023-06-15}} // 显示距离2023年6月15日还有/已过多少天 | ||
2025年8月21日 (四) 14:27的版本
倒计时模板
计算指定日期与当前时间的时间差,只输出数字结果。
使用方法
{{Countdown|目标日期|utc=时区|time=精度}}
参数
- 1
- 目标日期 (YYYY-MM-DD格式)
- 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}} → 包含时间的分钟差
1703980800
766
检测到模板循环:模板:Countdown // 显示距离2023年12月31日还有/已过多少天 检测到模板循环:模板:Countdown // 显示距离2023年6月15日还有/已过多少天
</noinclude> // 显示距离2023年12月31日还有/已过多少天
1686787200
965
检测到模板循环:模板:Countdown // 显示距离2023年12月31日还有/已过多少天 检测到模板循环:模板:Countdown // 显示距离2023年6月15日还有/已过多少天
</noinclude> // 显示距离2023年6月15日还有/已过多少天