timezone2 [Ubuntu] timezone 변경하기 1. 시간대 이름 확인// timezone 전체 목록 가져오기$ timedatectl list-timezones// timezone 목록에서 Seoul만 가져오기$ timedatectl list-timezones | grep SeoulAsia/Seoul 2. 시간대 변경$ sudo timedatectl set-timezone Asia/Seoul 3. 변경된 시간대 확인$ timedatectl Local time: Sun 2024-09-01 01:01:28 KST Universal time: Sat 2024-08-31 16:01:28 UTC RTC time: Sat 2024-08-31 16:01:28 .. 2024. 9. 1. new Date() timezone 적용하기 JS에서 new Date()를 이용해서 현재 시각을 콘솔에 찍어보면, toLocaleString을 적용했을 때와 9시간 차이가 나는 것을 확인할 수 있다. 이것은 한국 시간이 UTC보다 9시간 빠른 시간대이기 때문이다. const now = new Date(); console.log(now.toLocaleString()); // 4/10/2024, 8:57:11 PM => 현재 한국 시간 console.log(now); // 2024-04-10T11:57:11.268Z => ISO 8601 JS new Date()는 getTimezoneOffset이라는 함수를 지원하는데, 이것은 현재 타임존 offset을 분 단위로 제공한다. 한국의 경우 -540분을 해야 UTC와 같은 시간이 되기 때문에 getTime.. 2024. 4. 10. 이전 1 다음 반응형