Database holds timestamps in this format - 03:59:59
. Also I use third party plugin (autocomplete box) and it returns Date objects. I managed to use data from database in my plugin like below:
if (value) {
let splitTime = value.split(':')
date = new Date()
// If ...splitTime (spread operator) is used in below, compiler throws exeption - "Expected 1 or 4 arguments but got 0 or more" (I consider it as TS bug)
date.setHours(splitTime[0], splitTime[1], splitTime[2]);
// now I can use date string in my plugin
}
Are there any simple ways to transform Date object to 00:00:00
format? As I start it appears to look ugly:
'' + args.value.getHours() + ':' + args.value.getMinutes() + ':' + args.value.getSeconds())
Result is still not what is needed:
//=> 3:59:59
(notice - 3 is not 03)