-
[javascript] new Date()를 통해 getHours()하면 한국시간카테고리 없음 2024. 2. 14. 11:11const todayGMT = new Date();const today = new Date(todayGMT.getTime() + 1000 * 60 * 60 * 9);const year = today.getFullYear();const monthOneDigit = today.getMonth() + 1;const month = ('0' + monthOneDigit.toString()).slice(-2);const dateOneDigit = today.getDate();const date = ('0' + dateOneDigit.toString()).slice(-2);const hour = ('0' + today.getUTCHours()).slice(-2);const min = ('0' + today.getMinutes()).slice(-2);const sec = ('0' + today.getSeconds()).slice(-2);console.log('오늘날짜및 시간 한국 : today', today);console.log('시간은 ',hour,min,sec,'걍 gethours',today.getHours(),today.getUTCHours(),);
[출력결과]
오늘날짜및 시간 한국 : today 2024-02-14T11:08:37.456Z
시간은 11 08 37 걍 gethours 20 11반응형