he specified value "does not conform to the required format. The format is "yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS code example

Example: does not conform to the required format. The format is "yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS".

export function toDatetimeLocal(){
    const date = new Date(),
          ten = (i)=> ((i < 10 ? '0' : '') + i ),
    YYYY = date.getFullYear(),
    MTH = ten(date.getMonth() + 1),
    DAY = ten(date.getDate()),
    HH = ten(date.getHours()),
    MM = ten(date.getMinutes()),
    SS = ten(date.getSeconds())
    // MS = ten(date.getMilliseconds())

    return `${YYYY}-${MTH}-${DAY}T${HH}:${MM}:${SS}`


}

Tags:

Misc Example