javascript 영국시간 표시

0 투표
javascript 에서  영국시간을 표시하고 싶어요.

1 답변

0 투표

JavaScript에서 특정 시간대의 시간을 표시하려면 여러 가지 방법이 있습니다. 여기서는 `Intl.DateTimeFormat`을 사용하는 방법과 `Date.prototype.toLocaleString`을 사용하는 방법을 설명하겠습니다.

### `Intl.DateTimeFormat` 사용:

const date = new Date();
const options = { timeZone: 'Europe/London', year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' };
const formatter = new Intl.DateTimeFormat('en-GB', options);
console.log(formatter.format(date));

### `toLocaleString` 사용:

const date = new Date();
const options = { timeZone: 'Europe/London', year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' };
console.log(date.toLocaleString('en-GB', options));

위의 두 예제는 모두 영국시간을 'en-GB' 로케일과 함께 'Europe/London' 시간대로 표시합니다.

이 방법을 사용하면, JavaScript에서 영국 시간을 쉽게 표시할 수 있습니다.

add
...