Created
October 29, 2020 09:37
-
-
Save Gummiees/2e1a20c5d793e006b336962805f9cf82 to your computer and use it in GitHub Desktop.
Removes the date UTC offset with moment.js
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
/** Removes the current UTC offset. */ | |
public removeUtcOffset(utcDate: any): Date { | |
let date: Date; | |
if (utcDate instanceof Date) { | |
date = utcDate; | |
} else { | |
date = moment(utcDate, this.localGlobalService.getDashDateMomentFormat()).toDate(); | |
} | |
const noOffsetDate: Date = moment(date).utc().subtract(date.getTimezoneOffset(), 'm').toDate(); | |
return noOffsetDate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment