Created
February 3, 2021 08:15
-
-
Save simple17/d4fde1ecdb9f7af7b5c1594a3b3356b6 to your computer and use it in GitHub Desktop.
[DateTime to Date]
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 dateTimeToDate = (dotNetDate: string): Date => { | |
var re = /(\/Date\()(\d*)(\)\/)/; | |
var millisecondsString = dotNetDate?.replace(re, "$2") ?? ''; | |
return millisecondsString ? new Date(parseInt(millisecondsString)) : new Date(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment