Skip to content

Instantly share code, notes, and snippets.

@blackspike
Created March 22, 2023 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackspike/7c57b80fc747721e739b88b11256e50c to your computer and use it in GitHub Desktop.
Save blackspike/7c57b80fc747721e739b88b11256e50c to your computer and use it in GitHub Desktop.
const TWO_WEEKS_IN_MS = 14 * 24 * 60 * 60 * 1000; // 14 days in milliseconds
const targetDate = new Date('2023-03-10T14:45:04Z');
const currentDate = new Date();
if (currentDate.getTime() - targetDate.getTime() >= TWO_WEEKS_IN_MS) {
console.log('The target date is two weeks or older than the current date.');
return true;
} else {
console.log('The target date is less than two weeks older than the current date.');
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment