zoukankan      html  css  js  c++  java
  • js获取系统当前时间

     1<script language="JavaScript">
     2//日期 
     3var now = new Date(); //获取系统日期,即Sat Jul 29 08:24:48 UTC+0800 2006 
     4var yy = now.getYear(); //截取年,即2006 
     5var mm = now.getMonth(); //截取月,即07 
     6var dd = now.getDay(); //截取日,即29 
     7//取时间 
     8var hh = now.getHours(); //截取小时,即8 
     9var mm = now.getMinutes(); //截取分钟,即34 
    10var ss = now.getTime() % 60000//获取时间,因为系统中时间是以毫秒计算的, 
    11所以秒要通过余60000得到。 
    12ss = (ss - (ss % 1000)) / 1000//然后,将得到的毫秒数再处理成秒 
    13var clock = hh+':'; //将得到的各个部分连接成一个日期时间 
    14if (mm < 10) clock += '0'; //字符串 
    15clock += mm+':';  
    16if (ss < 10) clock += '0';  
    17clock += ss; 
    18</script>
  • 相关阅读:
    bzoj1415 NOI2005聪聪和可可
    Tyvj1952 Easy
    poj2096 Collecting Bugs
    COGS 1489玩纸牌
    COGS1487 麻球繁衍
    cf 261B.Maxim and Restaurant
    cf 223B.Two Strings
    cf 609E.Minimum spanning tree for each edge
    cf 187B.AlgoRace
    cf 760B.Frodo and pillows
  • 原文地址:https://www.cnblogs.com/wucf2004/p/575323.html
Copyright © 2011-2022 走看看