×

免费可定制的网站时钟组件

想在您自己的网站上显示精确的时间吗?或者想显示日期、昼长、日出日落时间?只需调整下列选项然后复制代码即可!完全免费!

选项

位置
美国紐約
可通过右上角的搜索框更改位置。
显示内容




时间格式



日期格式




 
天:
dayname星期二
dname周二
daynum01-31
dnum1-31
day_in_y天 1-366
周:
week12
月:
monthname3月
monthnum01-12
mnum1-12
年:
year2024
yy24
颜色和大小
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 参数可以继承,因此与前一组件相同的参数值无需重复定义。

 
 
2024年3月19日星期二,第12周
太阳: ↑ 06:58 ↓ 19:09 (12时 11分) - 更多信息 - 将紐約时间设为默认 - 取消关注此位置