×

为您的网站获取可定制的免费时钟小工具

想在您的网站上放置一个精确的时钟?或者要显示日期、日出/日落时间或昼长?只需从下面的选项中选择一个并复制其代码!免费!

选项

位置
美国纽约
要选择其他位置,请使用右上角的搜索框。
显示内容




时间格式



日期格式




 
天:
dayname星期四
dname周四
daynum01-31
dnum1-31
day_in_y天 1-366
周:
week17
月:
monthname4月
monthnum01-12
mnum1-12
年:
year2021
yy21
颜色和大小
px
预览
纽约时间:
最终结果可能不同,取决于您的网站使用的样式表。
您可以用 CSS 来任意定制小工具!

您的时钟小工具代码:

服务条款

高级用法

有两个版本的小工具脚本:简化版 t.js 只显示时间;普通版 zh.js 可以显示时间、日期、日出日落时间和昼长。普通版脚本有多种语言,要更改其语言,请将脚本名称中的 zh 替换为目标语言的代码。(如 pl.js 用于波兰语,tr.js 用于土耳其语。)

init 函数参数:

参数可用的值默认值
templateTIME, DATE, SUNTIME
time_formathours, minutes, seconds, 12hours, AMPMhours:minutes:seconds
date_formatdayname, dname, daynum, dnum, day_in_y, week, monthname, monthnum, mnum, yy, yearyear-monthnum-daynum
sun_formatsrhour, srminute, sr12hour, srAMPM, sshour, ssminute, ss12hour, ssAMPM, dlhours, dlminutessrhour:srminute-sshour:ssminute
coords经度和纬度。显示昼长和太阳时时必需。
id用于在服务器端标识位置和时区。当位置名称包含非 ASCII 字符或您更改了 HTML 的元素 ID 时必需。
callback一个函数名称。该函数以上述的 template 作为参数,并且每秒会被调用一次。(可选)

参数的名称和值都区分大小写。您可以在 templatetime_formatdate_formatsun_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>

结果:

UTC time:
New York sunrise time:
Tokyo sunrise time:
Find the current time for any location or time zone on Time.is!

time_formatdate_formatsun_formattemplate 参数的值是继承的,所以您无需重复定义相同的值。

 
 
2021年4月29日星期四,第17周
太阳: ↑ 05:56 ↓ 19:50 (13时 54分) 更多信息