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
|
||||
*/
|
||||
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);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue