0

我使用 date.js 有以下代码:

                <div id="Timer">
                    <script>Date.parse("hh:mm");</script> 
                    <div class="Timers">

                        <div class="timerSpace"><span style="text-align: left; color: #DDDD11;">Hours from now</span></div>
                        <div class="timer1"><span style="color: #FFFF11;"><script>var d1 = date.parse(Date.today().addHours(6.0)); document.write(d1);</script><span></div>
                        <div class="timer2"><span style="color: #FFFF11;"><script>var d2 = date.parse(Date.today().addHours(12.0)); document.write(d2);</script><span></div>
                        <div class="timer3"><span style="color: #FFFF11;"><script>var d3 = date.parse(Date.today().addHours(18.0));document.write(d3);</script><span></div>
                        <div class="timer4"><span style="color: #FFFF11;"><script>var d4 = date.parse(Date.today().addHours(24.0));document.write(d4);</script><span></div>
                        <div class="timerSpace"></div>
                    </div>
                </div>

而且我没有在我的页面上打印任何内容?为什么?

4

2 回答 2

1

代替

var d1 = date.parse(Date.today().addHours(6.0));

尝试

var d1 = new Date();
d1.setHours( d1.getHours() + 6 );
document.write( d1.toTimeString() );​

http://jsfiddle.net/P5RL6/

于 2012-10-23T13:51:06.510 回答
1

parse用于将现有解析StringDate对象。改用toString()

Date.today().toString("hh:mm")

另外,用于document.write写入文档,即:

<script>document.write(Date.today().toString("hh:mm"))</script>
于 2012-10-23T13:51:16.750 回答