为您的网站获取可定制的免费时钟小工具
想在您的网站上放置一个精确的时钟?或者要显示日期、日出/日落时间或昼长?只需从下面的选项中选择一个并复制其代码!免费!
选项
服务条款
- 您的网页上必须有一个清晰可见的指向 Time.is 的超链接。您可以翻译链接文本或改变其措辞,但必须包括 Time.is、时间、地区名称(圣彼得堡)或时区名称(MSK)。正确的链接文本:“圣彼得堡时间”、“圣彼得堡”、“当前时间”。错误的链接文本:“点击此处”。
- 您的网页不得自动刷新。
- 不得用于应用程序或脚本中。
- 小工具不受任何保证。
- 仅当您的网站重点不是这款小工具时,小工具才是免费的。
- 如果您未能遵守这些条款,Time.is 将封禁您的小工具。
高级用法
有两个版本的小工具脚本:简化版 t.js 只显示时间;普通版 zh.js 可以显示时间、日期、日出日落时间和昼长。普通版脚本有多种语言,要更改其语言,请将脚本名称中的 zh 替换为目标语言的代码。(如 pl.js 用于波兰语,tr.js 用于土耳其语。)
init 函数参数:
参数 | 可用的值 | 默认值 |
template | TIME, DATE, SUN | TIME |
time_format | hours, minutes, seconds, 12hours, AMPM | hours:minutes:seconds |
date_format | dayname, dname, daynum, dnum, day_in_y, week, monthname, monthnum, mnum, yy, year | year-monthnum-daynum |
sun_format | srhour, srminute, sr12hour, srAMPM, sshour, ssminute, ss12hour, ssAMPM, dlhours, dlminutes | srhour:srminute-sshour:ssminute |
coords | 经度和纬度。显示昼长和太阳时时必需。 | |
id | 用于在服务器端标识位置和时区。当位置名称包含非 ASCII 字符或您更改了 HTML 的元素 ID 时必需。 | |
callback | 一个函数名称。该函数以上述的 template 作为参数,并且每秒会被调用一次。(可选) |
参数的名称和值都区分大小写。您可以在 template、time_format、date_format 和 sun_format 参数中加入 HTML 代码和其他内容。
多个时钟可以这样创建:
UTC time: <span id="UTC_za00"></span><br/> New York sunrise time: <span id="New_York_z161"></span><br/> Tokyo sunrise time: <span id="Tokyo_z444"></span><br/> Find the <a href="https://time.is/" id="time_is_link" rel="nofollow">current time for any location or time zone on Time.is!</a> <script src="//widget.time.is/zh.js"></script> <script> time_is_widget.init({ UTC_za00 : {}, New_York_z161 : { template: "SUN", sun_format: "srhour:srminute", coords: "40.71427,-74.00597" }, Tokyo_z444 : { coords: "59.33258,18.06490" } }); </script>
结果:
time_format、date_format、sun_format 和 template 参数的值是继承的,所以您无需重复定义相同的值。