날짜를 필요한 형식 (YYYY-MM-DDTHH:MM:SS)으로 변환
/**
* NOTE: 날짜를 필요한 형식(YYYY-MM-DDTHH:MM:SS)으로 변환
* @function formatToSimpleISOString
* @param {string} dateString - 날짜 문자열
* @returns {string} - 변환된 날짜 문자열
*/
const formatToSimpleISOString = (dateTimeStr) => {
const date = new Date(dateTimeStr);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;
}
'JavaScript > 실무' 카테고리의 다른 글
[lib] mediamtx로 webrtc 구현하기 (0) | 2025.03.31 |
---|---|
[JS] 자주쓰는 정규표현식 (2) | 2024.11.12 |