这篇文章距离上次修改已过半年,其中的信息真实性可能已经有所发展或是发生改变,请自行分辨。

代码如下,附在网页代码即可。文字可适当修改,自测。

    <script language=javascript>
        function siteTime(){
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000
            var minutes = seconds * 60
            var hours = minutes * 60
            var days = hours * 24
            var years = days * 365
            var today = new Date()
            var todayYear = today.getFullYear()
            var todayMonth = today.getMonth()
            var todayDate = today.getDate()
            var todayHour = today.getHours()
            var todayMinute = today.getMinutes()
            var todaySecond = today.getSeconds()
            var t1 = Date.UTC(2016,1,13,6,00,00)
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond)
            var diff = t2-t1
            var diffYears = Math.floor(diff/years)
            var diffDays = Math.floor((diff/days)-diffYears*365)
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours)
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes)
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds)
            document.getElementById("sitetime").innerHTML="<br><center><b>迄今已运行 "+diffYears+' 年 '+diffDays+" 天  "+diffHours+" 时 "+diffMinutes+" 分 "+diffSeconds+" 秒</b></center>"
        }
        siteTime()
    </script>
    <script type="text/javascript">
    $('#weather').leoweather({format:'<strong>{年}年{月}月{日}日 星期{周} {时}:{分}:{秒}</strong>,</span> <b>{城市} {天气} {夜间气温}℃ ~ {白天气温}℃</b>'});
</script>

效果如下:
dm.png

扫描下面二维码,给博主打赏点吧~

微信

微信

支付宝

支付宝


作者:Lcry
本文链接:https://www.51it.wang/ll/152
商业转载请联系作者获得授权,非商业转载请注明本文出处及文章链接

带符号 * 的表示必填项