Created
July 10, 2022 01:23
-
-
Save olegchursin/382f863b7063dcd1117985e7439bec6d to your computer and use it in GitHub Desktop.
Get datetime default value for input field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getDatetimeDefaultValue = (timestamp: Date | string): string => { | |
let ts = new Date(); | |
if (timestamp) { | |
ts = new Date(timestamp); | |
} | |
ts.setMinutes(ts.getMinutes() - ts.getTimezoneOffset()); | |
ts.setMilliseconds(null); | |
ts.setSeconds(null); | |
return ts.toISOString().slice(0, -1); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment