날짜 포멧(2)
-
Javascript 날짜 포멧 설정
const now = new Date();// Create a custom format: YYYY-MM-DD HH:mm:ssconst year = now.getFullYear();const month = (now.getMonth() + 1).toString().padStart(2, '0'); // Month is zero-basedconst day = now.getDate().toString().padStart(2, '0');const hours = now.getHours().toString().padStart(2, '0');const minutes = now.getMinutes().toString().padStart(2, '0');const seconds = now.getSeconds().toStrin..
2024.11.24 -
Javascript 날짜 포멧 설정하기
오라클이나, 자바처럼 formatter같은게 없는 것 같음HH24MIfunction formatDateToHH24MM(date) { // Extract hours and minutes let hours = date.getHours().toString().padStart(2, '0'); // Ensure 2 digits let minutes = date.getMinutes().toString().padStart(2, '0'); // Ensure 2 digits // Return formatted string return hours + minutes;}YYYMMDDfunction getYearMonthDay(date) { let year = date.getFullYear();..
2024.11.23