Files
timetracker/games/static/js/utils.js
Lukáš Kucharczyk 81f6522f88
All checks were successful
continuous-integration/drone/push Build is passing
input datetime-local needs day to also be two digits
2023-03-02 17:26:44 +01:00

11 lines
377 B
JavaScript

/**
* @description Formats Date to a UTC string accepted by the datetime-local input field.
* @param {Date} date
* @returns {string}
*/
export function toISOUTCString(date) {
let month = (date.getMonth() + 1).toString().padStart(2, 0);
let day = date.getDate().padStart(2, 0);
return `${date.getFullYear()}-${month}-${day}T${date.getHours()}:${date.getMinutes()}`;
}