在倒计时中设置时区

时间:2013-02-07 16:51:13

标签: javascript date timezone countdown

我有类似下面的代码,我想为它设置时区。我可以知道我该怎么办?

代码:

<script type="text/javascript">
  $(function () {
    var year = new Date();

    year = new Date(year.getFullYear(), 11 - 1, 20);

    $('#dvCountDown').countdown({
      until: new Date('2013-02-08'),
      format: 'HMS',
      onExpiry: liftOff
    });

    $('#CountdownbyValue').countdown({
      until: '0h +0m +8s',
      format: 'HMS',onExpiry: liftOff
    });

    $('#year').text(austDay.getFullYear());

    //Time is up!
    function liftOff() { 
      alert('Time is up!'); 
    }

  });
</script>

1 个答案:

答案 0 :(得分:0)

尝试使用它:

var year = new Date();
year.setUTCMonth(11 - 1);
year.setUTCDay(20);
year.setUTCHour( /* your timezone offset */ );
year.setUTCMinutes( /* your timezone offset */ );
year.setUTCSeconds(0);

$('#dvCountDown').countdown({
  until: new Date(Date.UTC(2013, 2-1, 08)),
  format: 'HMS',
  onExpiry: liftOff
});