Javascript 시간 더하기

2024. 12. 5. 18:02Javascript

function addMinutesToCurrentTime(minutesToAdd) {
    const now = new Date(); // Get the current date and time
    now.setMinutes(now.getMinutes() + minutesToAdd); // Add 15 minutes
    return now;
}

// Example usage
const updatedTime = addMinutesToCurrentTime(15);
console.log(updatedTime.toLocaleTimeString('en-US', { hour12: false })); // Example output: "15:30:00" (24-hour format)