Simplified iso date
This commit is contained in:
parent
46194ab4fe
commit
47032055b6
1 changed files with 12 additions and 7 deletions
|
@ -64,13 +64,17 @@ export const helperService = {
|
||||||
* @returns Date as string in the used format
|
* @returns Date as string in the used format
|
||||||
*/
|
*/
|
||||||
toISODate(date) {
|
toISODate(date) {
|
||||||
var timezoneOffset = date.getMinutes() + date.getTimezoneOffset();
|
return (
|
||||||
var timestamp = date.getTime() + timezoneOffset * 1000;
|
date.getFullYear() +
|
||||||
var correctDate = new Date(timestamp);
|
"-" +
|
||||||
|
(date.getMonth() + 1).toString().padStart(2, "0") +
|
||||||
correctDate.setUTCHours(0, 0, 0, 0);
|
"-" +
|
||||||
|
date
|
||||||
return correctDate.toISOString();
|
.getDate()
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0") +
|
||||||
|
"T00:00.000Z"
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,6 +85,7 @@ export const helperService = {
|
||||||
* @returns Date as string in YYYY-MM-DD format
|
* @returns Date as string in YYYY-MM-DD format
|
||||||
*/
|
*/
|
||||||
toISODateOnly(date) {
|
toISODateOnly(date) {
|
||||||
|
console.log(helperService.toISODate(date));
|
||||||
return helperService.toISODate(date).substring(0, 10);
|
return helperService.toISODate(date).substring(0, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue