Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

시간과 시계

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

This API is available on Firefox OS for certified applications only.

요약

Time/Clock API로 시스템 시간을 쉽게 바꿀 수 있습니다.

개요

이 API는 navigator.mozTime 을 통해 리턴되는, MozTimeManager 객체를 통해 접근할 수 있습니다. 해당 객체는 하나의 set() 메서드를 가지고 있습니다.

set() 메서드는 시스템 시간을 변경하는데 이용됩니다. 파라미터로는 숫자(=Number) 객체 또는 Date 객체가 사용됩니다. 만약 숫자 객체가 사용된다면 해당 숫자는 UTC 1970년 1월 1일 부터의 밀리초를 의미합니다.

시간이 변경될 때마다 이벤트가 발생하게 됩니다. 이 이벤트는 window 객체에서 addEventListener  메서드 를 통해(이벤트명은  moztimechange) 처리하거나, 또는 window.onmoztimechange 속성에 이벤트 핸들러를 연결함으로써 처리할 수 있습니다.

주: 기기의 시간대는 Settings API로 바꿔야 합니다.

예시

function setTime(time) {
  navigator.mozTime.set(time);
}

window.addEventListener('moztimechange', function () {
  console.log('시간이 바뀜');
});

setTime(new Date());

표준

어느 표준에도 들어있지 않음

문서 태그 및 공헌자

 이 페이지의 공헌자: sangpire, Ephemera, jincreator
 최종 변경: sangpire,