{"id":34,"date":"2024-01-17T17:27:50","date_gmt":"2024-01-17T17:27:50","guid":{"rendered":"https:\/\/sadpoetryhub.com\/?page_id=34"},"modified":"2024-01-17T17:27:50","modified_gmt":"2024-01-17T17:27:50","slug":"age-calculator","status":"publish","type":"page","link":"https:\/\/sadpoetryhub.com\/?page_id=34","title":{"rendered":"AGE CALCULATOR"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>Date Duration Calculator<\/title>\n<style>\n  body {\n    font-family: Arial, sans-serif;\n  }\n  .container {\n    max-width: 900px;\n    margin: 0 auto;\n    padding: 20px;\n    border: 1px solid #ddd;\n    border-radius: 5px;\n    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n  }\n  label {\n    font-weight: bold;\n    display: block;\n    margin-bottom: 5px;\n  }\n  input[type=\"date\"] {\n    width: 100%;\n    padding: 8px;\n    margin-bottom: 10px;\n    border: 1px solid #ddd;\n    border-radius: 3px;\n  }\n  button {\n    background-color: #007bff;\n    color: white;\n    border: none;\n    padding: 10px 20px;\n    border-radius: 3px;\n    cursor: pointer;\n  }\n  #result {\n    margin-top: 10px;\n  }\n  table {\n    width: 100%;\n    border-collapse: collapse;\n    margin-top: 10px;\n  }\n  table, th, td {\n    border: 1px solid #ddd;\n    padding: 8px;\n    text-align: left;\n  }\n<\/style>\n<\/head>\n<body>\n  <div class=\"container\">\n    <h1>Date Duration Calculator<\/h1>\n    <label for=\"startDate\">Select start date:<\/label>\n    <input type=\"date\" id=\"startDate\">\n    <label for=\"endDate\">Select end date:<\/label>\n    <input type=\"date\" id=\"endDate\">\n    <button id=\"calculateBtn\">Calculate Duration<\/button>\n    <div id=\"result\">\n      <table id=\"resultTable\">\n        <tr>\n          <th>Duration Type<\/th>\n          <th>Duration<\/th>\n        <\/tr>\n      <\/table>\n    <\/div>\n  <\/div>\n\n  <script>\n    const calculateBtn = document.getElementById(\"calculateBtn\");\n    const resultTable = document.getElementById(\"resultTable\");\n\n    calculateBtn.addEventListener(\"click\", calculateDuration);\n\n    function calculateDuration() {\n      const startDateInput = document.getElementById(\"startDate\");\n      const endDateInput = document.getElementById(\"endDate\");\n\n      const startDate = new Date(startDateInput.value);\n      const endDate = new Date(endDateInput.value);\n\n      if (startDate > endDate) {\n        showErrorMessage(\"Start date cannot be later than end date.\");\n        return;\n      }\n\n      const diffInMilliseconds = endDate - startDate;\n      const diffInSeconds = diffInMilliseconds \/ 1000;\n      const diffInMinutes = diffInSeconds \/ 60;\n      const diffInHours = diffInMinutes \/ 60;\n      const diffInDays = diffInHours \/ 24;\n      const diffInDaysIncludingLast = diffInDays + 1;\n\n      const years = Math.floor(diffInDays \/ 365);\n      const months = Math.floor((diffInDays % 365) \/ 30);\n      const days = Math.floor(diffInDays % 30);\n\n      const hours = Math.floor(diffInHours % 24);\n      const minutes = Math.floor(diffInMinutes % 60);\n      const seconds = Math.floor(diffInSeconds % 60);\n\n      displayResult([\n        [\"Start Date\", startDate.toDateString()],\n        [\"End Date\", endDate.toDateString()],\n        [\"Duration\", `${years} years, ${months} months, ${days} days`],\n        [\"Duration (days)\", diffInDays.toFixed(2)],\n        [\"Including End Date\", diffInDaysIncludingLast.toFixed(2)],\n        [\"Total Hours\", `${Math.floor(diffInHours)} hours`],\n        [\"Total Minutes\", `${Math.floor(diffInMinutes)} minutes`],\n        [\"Total Seconds\", `${Math.floor(diffInSeconds)} seconds`]\n      ]);\n    }\n\n    function showErrorMessage(message) {\n      resultTable.innerHTML = `\n        <tr>\n          <td colspan=\"2\" style=\"color: red;\">${message}<\/td>\n        <\/tr>\n      `;\n    }\n\n    function displayResult(data) {\n      resultTable.innerHTML = \"\";\n      for (const item of data) {\n        resultTable.innerHTML += `\n          <tr>\n            <td>${item[0]}<\/td>\n            <td>${item[1]}<\/td>\n          <\/tr>\n        `;\n      }\n    }\n  <\/script>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Date Duration Calculator Date Duration Calculator Select start date: Select end date: Calculate Duration Duration Type Duration<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-34","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/sadpoetryhub.com\/index.php?rest_route=\/wp\/v2\/pages\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sadpoetryhub.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sadpoetryhub.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sadpoetryhub.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sadpoetryhub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34"}],"version-history":[{"count":0,"href":"https:\/\/sadpoetryhub.com\/index.php?rest_route=\/wp\/v2\/pages\/34\/revisions"}],"wp:attachment":[{"href":"https:\/\/sadpoetryhub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}