Simplified iso date

This commit is contained in:
Maximilian Giller 2022-02-02 14:22:18 +01:00
parent 46194ab4fe
commit 47032055b6

View file

@ -64,13 +64,17 @@ export const helperService = {
* @returns Date as string in the used format
*/
toISODate(date) {
var timezoneOffset = date.getMinutes() + date.getTimezoneOffset();
var timestamp = date.getTime() + timezoneOffset * 1000;
var correctDate = new Date(timestamp);
correctDate.setUTCHours(0, 0, 0, 0);
return correctDate.toISOString();
return (
date.getFullYear() +
"-" +
(date.getMonth() + 1).toString().padStart(2, "0") +
"-" +
date
.getDate()
.toString()
.padStart(2, "0") +
"T00:00.000Z"
);
},
/**
@ -81,6 +85,7 @@ export const helperService = {
* @returns Date as string in YYYY-MM-DD format
*/
toISODateOnly(date) {
console.log(helperService.toISODate(date));
return helperService.toISODate(date).substring(0, 10);
},