테스트 사이트 - 개발 중인 베타 버전입니다

ClassyCountdown 한국시간 적용방법 채택완료

스카이라이퍼 2년 전 조회 1,921

https://www.jqueryscript.net/demo/Slick-Circular-jQuery-Countdown-Plugin-Classy-Countdown/">jQuery Classy Countdown Plugin Demos (jqueryscript.net)에서 카운트 다운을 다운받아 그누보드에 설치해 봤습니다. 그런데 9시간 느리게 카운드 다운이 되네요. 한국시간으로 UTC+9 하여 카운트 되도록 하는 방법을 도저히 모르겠네요. 

저는 다음과 같이 작성해봤습니다. 

</strong></p>

<p><script type="text/javascript">

$(document).ready(function() {

  $('#countdown17').ClassyCountdown({

    theme: "flat-colors-very-wide",

    now: Math.round(new Date().getTime() / 1000),

    end: Math.round(new Date('<?php            

            echo $list[$i]['datetime2'] = date("Y", strtotime($list[$i]['wr_datetime']));

             ?>-<?php            

            echo $list[$i]['datetime2'] = date("m", strtotime($list[$i]['wr_datetime']));

             ?>-<?php            

            echo $list[$i]['datetime2'] = date("d", strtotime($list[$i]['wr_datetime']));

             ?>T<?php            

            echo $list[$i]['datetime2'] = date("H", strtotime($list[$i]['wr_datetime']));

             ?>:<?php            

            echo $list[$i]['datetime2'] = date("i", strtotime($list[$i]['wr_datetime']));

             ?>Z').getTime() / 1000),

    onEndCallback: function() {},

    events: {

      onTick: function(event) {

        var $this = $(this).find('.ClassyCountdown-seconds');

        if (event.offset.seconds <= 5) {

          $this.addClass('flash');

        } else {

          $this.removeClass('flash');

        }

      }

    },

    timezone: "Asia/Seoul" // 한국 시간으로 설정합니다.

  });

});

</script></p>

<p><strong>

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

챗 GPT가 해결해 주었습니다. 

 

<script type="text/javascript">
$(document).ready(function() {
  $('#countdown17').ClassyCountdown({
    theme: "flat-colors-very-wide",
    now: $.now() / 1000, // 현재 시간
    end: new Date("<?php            
            echo $list[$i]['datetime2'] = date("Y", strtotime($list[$i]['wr_datetime']));
             ?>/<?php            
            echo $list[$i]['datetime2'] = date("m", strtotime($list[$i]['wr_datetime']));
             ?>/<?php            
            echo $list[$i]['datetime2'] = date("d", strtotime($list[$i]['wr_datetime']));
             ?> <?php            
            echo $list[$i]['datetime2'] = date("H", strtotime($list[$i]['wr_datetime']));
             ?>:<?php            
            echo $list[$i]['datetime2'] = date("i", strtotime($list[$i]['wr_datetime']));
             ?>:00").getTime() / 1000, // 종료 시간
    onEndCallback: function() {
      alert("카운트다운이 종료되었습니다!");
    }
  });
});
</script>

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

m
2년 전

</p>

<p>const utc = new Date().getTime() + (new Date().getTimezoneOffset() * 60 * 1000);

const KR_TIME_DIFF = 9 * 60 * 60 * 1000;

const kr_time = new Date(utc + (KR_TIME_DIFF));</p>

<p>

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인