用getSeconds()可以得到当前秒数
看到一个用getTime()得到的:
var now = new Date();
var ss = now.getTime() % 60000;   
ss = (ss - (ss % 1000)) / 1000; 
document.write(ss);
不大理解,请教一下

解决方案 »

  1.   

    var now = new Date(); //now为当前时间(日期+时间),这个没问题吧?
    var ss = now.getTime() % 60000;  //得到now里的时间,%6000这个得到毫秒数。
    ss = (ss - (ss % 1000)) / 1000; //毫秒除1000得秒。
    document.write(ss); //这个知道吧??
      

  2.   

    getTime() 方法可返回距 1970 年 1 月 1 日之间的毫秒数。getSeconds() 方法可返回时间的秒,返回值是 0 ~ 59 之间的一个整数。
    如:
    <script type="text/javascript">var Birthday = new Date("July 21, 1983 01:15:00")
    document.write(Birthday.getSeconds())</script>
    返回值是:0
    有什么问题么?
      

  3.   

    Date.getSeconds( ): return the seconds field of a Date
      

  4.   

    Date.getTime( ): return a Date in milliseconds
    getTime( ) converts a date and time to a single integer. Date.getMilliseconds( ): return the milliseconds field of a Date