Skip to content

Instantly share code, notes, and snippets.

@simple17
Created February 3, 2021 08:15
Show Gist options
  • Save simple17/d4fde1ecdb9f7af7b5c1594a3b3356b6 to your computer and use it in GitHub Desktop.
Save simple17/d4fde1ecdb9f7af7b5c1594a3b3356b6 to your computer and use it in GitHub Desktop.
[DateTime to Date]
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