js统计网站运行时长

js统计网站运行时长

浏览次数:
作者: 墨鱼
信息来源: 本站原创
更新日期: 2017-03-04 23:33:09
文章简介

JS精准统计网站运行时长,实时反馈,帮助用户了解网页性能。无需复杂设置,简单调用即可实现。通过优化算法,确保数据准确可靠,为用户提供更好的网页体验。

  • 正文开始
  • 相关阅读
  • 推荐作品

 

 
 
js统计网站运行时长
 
第一种:
 网站<span id="sitetime"></span>
<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()
/* Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
year - 作为date对象的年份,为4位年份值
month - 0-11之间的整数,做为date对象的月份
day - 1-31之间的整数,做为date对象的天数
hours - 0(午夜24点)-23之间的整数,做为date对象的小时数
minutes - 0-59之间的整数,做为date对象的分钟数
seconds - 0-59之间的整数,做为date对象的秒数
microseconds - 0-999之间的整数,做为date对象的毫秒数 */
var t1 = Date.UTC(2016,5,2,11,19,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=" 已运行"+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒"
}
siteTime()
</script>
 
注释:代码中的 var t1 = Date.UTC(2016,5,2,11,19,00) 是网站上线时间(自己定义),2016,5,2,11,19,00 为 2016年4月2日11点19分00秒(月份0-11之间的整)
 
 
第二种:
网站已运行<script language="javascript">
var now=new Date();var spday=new Date(2016,09,22);a=(now.getTime()-spday.getTime())/(24*60*60*1000);a=Math.ceil(a); document.write
("<b>"+a+"</b>");</script>天
 
注释:代码中的 Date(2016,09,22) 是网站上线时间(自己定义),2016,09,22 为 2016年8月22日(月份0-11之间的整)
 
Html页面高度导致抖动问题的原因以及解决方案(CSS方案)
« 上一篇 2016年12月15日
解决百度地图api设置点的图标不显示
下一篇 » 2017年09月04日

    Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2016-05-23/9cee26298570808a071feed884f6cc3a.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 【高端定制】自适应HTML5响应式大气图片博客模板 - 帝国CMS整站源码手机友好
    3.9k阅读0条评论0个赞
    帝国CMS新核心,安全稳定高效。大气美观设计,专为博客图片展示定制。支持定制扩展,视频播放等需求满足。手机自适应,高端站长首选!支持二级目录灵活设置。

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2021-01-23/6ec394d7d9f1e29b526a930ef30dae5f.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS 7.5 HTML5响应式APP下载&手赚网赚平台游戏分享整站模板
    1.7k阅读0条评论0个赞
    基于帝国CMS 7.5 utf8版本,本模板为APP下载、手赚网赚及游戏分享量身打造。HTML5响应式自适应设计,无论PC或手机,都能流畅访问,助您轻松搭建功能全面的在线平台。

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2022-02-14/b536f23e83b6788eeeaa0333f40efb0f.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS淘宝客导购模板 - 漂亮大气,快速响应HTML5,手机平板自适应
    1.8k阅读0条评论0个赞
    采用帝国CMS最新版核心,扁平化设计风格,打造高端大气、快速流畅的淘宝客导购类网站模板。完美适应手机、平板等多终端浏览,所有修改均可后台轻松管理。集成标签TAG拼音化自动URL,优化SEO,提升搜索引擎排名。导购栏目与内容模板分离设计,首页智能识别,展现多元前端效果,助力站长高效运营。

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2017-07-26/af307123a30a998a21a121eaf10ceced.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 全能资讯站:帝国CMS自适应HTML5响应式整站模板,轻松驾驭新闻博客图片
    2.7k阅读0条评论0个赞
    帝国CMS新版驱动,构建资讯新闻博客全能站。模板自适应手机与平板,图片精简美观,SEO友好。独特侧边栏设计,提升浏览体验,操作便捷。适用于资讯发布、新闻更新、个人博客、图片展示等多场景,助力您轻松打造高端在线平台。

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2022-07-01/f12a0dfde82f4d6facbaa3390551afd4.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS瀑布流图片博客模板:自适应HTML5,整站源码,摄影文章一网打尽
    764阅读0条评论0个赞
    新版帝国CMS整站源码,安全高效运行。HTML5全自适应,移动设备浏览无忧。内置新版会员中心,优化用户体验。TAG自动拼音化URL,SEO友好。瀑布流布局,专为摄影博客定制。

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2016-08-22/cc514ded1e9731c3a3229bd96f2b3901.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 瀑布流图片网站模版 | HTML5自适应响应式帝国CMS后台整站源码,手机平板无缝浏览
    4.8k阅读0条评论10个赞
    采用帝国CMS新版核心,打造瀑布流图片站。整站设计大气简约时尚,安全高效运行无忧。全面适配手机平板,到手即用,轻松开启图片展示之旅!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2019-10-19/704588f900aea6b72838c1269fff813d.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 企业展示新选择:帝国CMS模板,HTML5响应式自适应,全站企业产品展示
    1.9k阅读0条评论0个赞
    采用帝国CMS新版核心,打造高端企业展示平台。涵盖产品案例、新闻、单页简介等丰富栏目,全方位展现企业形象与产品实力。后台管理简便,安全高效,性能卓越。全站响应式设计,手机平板浏览效果俱佳,助您快速构建专属企业展示形象!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2015-05-10/c96fdf4f295fa0fea3fe1a6781982843.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 个人博客&新闻资讯帝国CMS模板 - 自适应HTML5手机响应
    3.1k阅读0条评论0个赞
    适用于个人博客、新闻资讯自媒体网站,整站简洁,自适应手机等移动设备。改LOGO、网站名、栏目名,即可上线运营!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2022-11-27/d59875b32db92cdc1da0b85b4c0a3bb3.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS整站模板:个人博客、新闻资讯、图片展示,自适应HTML5手机浏览
    931阅读0条评论0个赞
    采用帝国CMS新版核心,模板内置SEO深度优化,广告位巧妙设计避免被主流浏览器屏蔽。完美适配个人博客、新闻资讯、文章分享及图片展示类网站,自适应手机与平板,后台管理便捷高效,让建站变得简单又快速!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2018-11-10/26bf06417fb8e65f37369318dacb752f.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS整站模板:手机自适应HTML5新闻资讯门户,支持视频收费播放与下载
    9.8k阅读10条评论0个赞
    采用帝国CMS新版核心,构建高效安全新闻资讯门户。全后台操作,无需编程,轻松配置首页布局。内置SEO优化,提升搜索引擎排名。多样栏目样式,满足个性化需求。支持MP4、M3U8视频多终端播放,实现视频收费与下载权限控制。一键部署,即刻开启盈利运营!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2015-05-10/0cc64f8c3cb094abfcacb5d7ace9125c.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS自适应HTML5整站模板 - 博客工作室新闻资讯手机响应
    1.9k阅读0条评论0个赞
    采用帝国CMS最新版,适合个人博客、工作室、自媒体网站。HTML5响应式,支持手机等移动设备,性能稳定安全,功能强大易扩展!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2021-11-07/4ccfbedc07635d65885ff95a25e3cd12.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS高效整站模板 - 文章下载/图片视频/商城淘宝客,自适应HTML5响应式
    2.4k阅读0条评论0个赞
    精选帝国CMS最新核心,打造高效运营整站模板。简约而不失功能,专为个人站长量身优化。资源丰富即可快速上线,全面支持手机平板自适应浏览,开启您的互联网创业之旅!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2022-11-04/17f1db119779129c056fcac181653b7d.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS美女摄影模板 - 多终端适配,手机专用,高端大气图片站
    5.0k阅读0条评论0个赞
    帝国CMS新版力作,打造安全高效的美女摄影站。设计简约而不失奢华,专为手机优化,图片展示效果震撼,浏览流畅省力。内置广告模式,百度图加广告轻松实现高收益。无论是浏览美图还是商业运营,都是您的理想之选。更多精彩,尽在指尖滑动间,快来体验吧!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2016-06-09/a97a0703a56e3f349cb6294531c7d9fc.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS源码 - 文章新闻图片电影视频下载商城 - 自适应HTML5响应式手机
    6.5k阅读0条评论0个赞
    移植国外知名模板,墨鱼优化改造。支持新闻、图片、文件下载(设权限)、视频播放(自适应)、商品出售(含支付接口/淘宝客)。多种列表模板,支持MP3/MP4/FLV播放,自适应移动设备,到手即用,适合工作室或个人。

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2015-05-09/64745314aa9b2269cf41ddd4892eea95.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS个人博客&资讯模板 - 自适应HTML5响应式手机站
    2.2k阅读0条评论0个赞
    专为个人博客、文章资讯类站点设计,代码整洁高效,加载快!完美自适应移动设备,到手即开站,SEO预设。支持MP4、M3U8播放,权限控制,扣点收费。五种内容样式自动处理!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2023-01-12/1673498488167368.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS企业展示模板:整站HTML5响应式,手机自适应,产品案例新闻一网打尽
    2.7k阅读0条评论0个赞
    采用帝国CMS新版核心,打造全方位企业展示模板。涵盖产品案例、新闻动态、单页简介等丰富栏目,完美呈现企业形象与产品魅力。后台操作简便,安全可靠,性能卓越。特别集成TAG拼音化URL SEO插件,助力搜索引擎优化。整站响应式设计,手机平板浏览同样高端大气,快速构建专属企业展示平台!

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2019-04-27/0aae04419466b54a7b33febc8228a1ee.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 宽屏帝国CMS模板:会员付费视频、下载、新闻资讯,HTML5自适应响应式
    1.8k阅读0条评论0个赞
    以帝国CMS新版为核心,打造安全高效的宽屏模板。后台操作简便,无需代码基础。首页多样式展示,自动填入ID即现。支持MP4、M3U8等多终端播放,并集成权限控制与扣点收费功能。下载同样实现扣点与权限管理。内置五种内容样式,智能识别显示。栏目与文章缩略图自动判断,无图时显示默认图,一键部署,轻松运营。

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2021-09-06/762e6ccc457acb5ecabc04b7314881cb.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS源码商城模板 - 虚拟货源软件下载,自适应HTML5响应式手机整站
    3.6k阅读1条评论0个赞
    精选帝国CMS最新版核心,打造安全高效运营平台。模板设计简洁实用,聚焦站长运营需求,减少冗余元素。手握优质资源,即刻启动商城运营,全站自适应手机平板,畅享无忧移动体验。

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2021-12-15/8af707ef59306f067e0028eaf822011a.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS整站模板 - 自适应HTML5,新闻资讯/个人博客/视频收费播放下载
    1.2k阅读0条评论0个赞
    精选帝国CMS新版核心,打造安全高效整站模板。后台操作简便,无需编码知识。支持MP4、M3U8等多终端播放,内置权限控制与扣点收费功能。下载同样支持权限与扣点,一键部署,即刻运营!内置五种智能内容样式,自动适应不同内容需求。

  • Warning: file_exists(): open_basedir restriction in effect. File(/www/wwwroot/moyubuluo.com/d/file/2024-10-17/1729153164527954.jpg) is not within the allowed path(s): (/www/wwwroot/moyubuluo.com/:/tmp/) in /www/wwwroot/moyubuluo.com/e/class/t_functions.php on line 2808
  • 帝国CMS资讯知识文章响应式模板 - 图文博客自媒体,自适应手机平板
    1.4k阅读0条评论0个赞
    采用帝国CMS7.5内核开发,整站安全可靠。前端采用响应式HTML5模板,适合图文自媒体、博客、资讯文章新闻等多领域使用。通过简单替换文字图片,即可应用于其他行业。

如本文对您有帮助,就请墨鱼抽根烟吧!