Skip to content

Instantly share code, notes, and snippets.

@Davisonpro
Created July 24, 2023 21:14
Show Gist options
  • Save Davisonpro/2fd46f6d2e08f423f30e74d8582dbb54 to your computer and use it in GitHub Desktop.
Save Davisonpro/2fd46f6d2e08f423f30e74d8582dbb54 to your computer and use it in GitHub Desktop.
// Calculate the time elapsed since a specific date (example: January 1, 2023)
const specificDate = new Date('January 1, 2023');
const timeElapsed = currentDateTime - specificDate;
const daysElapsed = Math.floor(timeElapsed / (1000 * 60 * 60 * 24));
// Display all date and time information in the span element
datetimeDisplayElement.textContent = `Days Elapsed since January 1, 2023: ${daysElapsed}`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment