Hadith of the Day | Free Daily Authentic Hadith Generator

Free · No sign-up · Updates every day

Hadith of the Day

A new authentic Hadith of the Day, every day β€” pulled from Sahih al-Bukhari, Sahih Muslim, and Jami’ at-Tirmidhi, each one with a checkable reference number so you never have to take our word for it.

πŸ“– Sahih al-Bukhari & Muslim only πŸ”’ Real reference numbers πŸ•°οΈ Changes automatically each day πŸ”’ Runs in your browser 🚫 No AI-generated hadith text

This Hadith of the Day tool runs entirely on your device β€” nothing you do here is sent to a server, and no account is required.

See Today’s Hadith ↓
Hadith of the Day tool showing a daily hadith card with source reference

Today’s Hadith of the Day

Browse by theme, or just read what’s come up for today. Every card below is one of a fixed set of hadith we’ve individually checked against sunnah.com before adding it here β€” this tool does not write or paraphrase hadith text on the fly.

β€”
Sahih

Loading…

Loading today’s hadith…

What Is a Hadith?

A hadith is a report of something the Prophet Muhammad ο·Ί said, did, or approved of, passed down through a chain of narrators (an isnad) back to someone who witnessed it. Scholars of hadith spent centuries cross-checking these chains β€” who narrated from whom, how reliable each narrator was, whether the wording matched other transmissions of the same report β€” before sorting hadith into collections like Sahih al-Bukhari and Sahih Muslim.

That’s why every entry in this Hadith of the Day tool is labeled with its collection, its hadith number, and an authenticity grade (Sahih or Hasan) β€” the same way you’d cite a page number when quoting a book, because a hadith without a reference is very hard to verify.

Hadith of the Day card showing narrator, collection, and hadith reference number

How This Hadith of the Day Generator Works

  1. Pick today’s date, or a theme. By default the tool works out the day of the year and uses it to select one hadith from a fixed local set β€” so everyone visiting on the same day sees the same Hadith of the Day. You can also jump straight to a theme like Patience or Charity.
  2. The reference is looked up, not invented. Every hadith is stored locally with its narrator, its exact collection and number, and an authenticity grade that was checked against sunnah.com before publishing.
  3. The card is assembled. The tool fills in the theme tag, the English translation, the citation, and a one-line reflection, then renders it into the calendar-leaf card below.
  4. You copy, print, or save it. Copy pulls plain text with the reference included; Print opens a clean, distraction-free version; Download saves a .txt file you can keep.
Diagram showing how the Hadith of the Day tool selects and displays a daily hadith

What Should a Reliable Hadith Reference Include?

Before you trust or share any hadith you find online β€” including from this Hadith of the Day tool β€” check that it names:

  • βœ… The narrator (the Companion who reported it)
  • βœ… The collection it’s found in (e.g. Sahih al-Bukhari, Sahih Muslim, Jami’ at-Tirmidhi)
  • βœ… A specific hadith number, not just “narrated by Bukhari”
  • βœ… An authenticity grade β€” Sahih (rigorously authenticated), Hasan (well authenticated), or weaker
  • βœ… A translation you can trace back to a named source, not an unattributed graphic

A Worked Example: Anatomy of a Hadith of the Day Card

Here’s exactly how one entry β€” the very first hadith in Sahih al-Bukhari β€” is broken down inside this tool:

NarratorUmar ibn al-Khattab
CollectionSahih al-Bukhari
ReferenceHadith 1
GradeSahih (agreed upon by Bukhari & Muslim)
ThemeIntention & Sincerity
Translation“Actions are judged by intentions, and every person will get the reward according to what he intended.”

Who Uses a Hadith of the Day Tool Like This

Personal daily reflection

One short, sourced hadith to open or close your day β€” light enough to actually keep up with.

Teachers & homeschool parents

A ready reference with a real citation for weekly Islamic studies lessons, without having to dig through a full collection yourself.

Reverts & new Muslims

A gentle, themed introduction to the Sunnah β€” one clearly-sourced hadith at a time, instead of an overwhelming full text.

Content creators & da’wah accounts

A Hadith of the Day you can quote publicly with confidence, because the reference is already attached.

Best Practices for Sharing a Hadith of the Day

  • Always share the reference alongside the text β€” collection, number, and grade β€” not the wording alone.
  • When in doubt about a hadith’s authenticity, check it directly on Sunnah.com, the reference database this tool’s citations were checked against.
  • Read a hadith in the context of the chapter it sits in β€” a single line taken in isolation can read differently than it did in its original setting.
  • Treat rulings (halal/haram questions) as something to confirm with a qualified scholar, not to settle from a single hadith card.

Common Mistakes When Sharing a Hadith of the Day

  • Sharing without a reference. A hadith with no collection or number is nearly impossible for anyone else to verify.
  • Mixing weak or fabricated hadith in with authentic ones. Some widely-shared “hadith” β€” including a few famous ones β€” have weak or no chain of narration at all.
  • Trusting unsourced social media graphics. A nicely designed image is not the same thing as a checked reference.
  • Treating one translation as the final word. Translations can lose nuance; scholarly commentary (sharh) exists for a reason.
  • Skipping the authenticity grade. Sahih, Hasan, and Da’if hadith are not interchangeable in how much weight they carry.

Hadith of the Day β€” Frequently Asked Questions

What makes a Hadith of the Day authentic?

An authentic (Sahih) hadith has an unbroken chain of trustworthy narrators back to the Prophet ο·Ί, verified by hadith scholars over centuries. This tool only includes hadith graded Sahih or Hasan, each labeled with its collection and reference number so you can check it yourself.

Where do the hadith in this Hadith of the Day tool come from?

Every hadith is sourced from Sahih al-Bukhari, Sahih Muslim, or Jami’ at-Tirmidhi, and each entry’s wording and reference number were checked against sunnah.com before being added to the tool.

Does the Hadith of the Day change for everyone at the same time?

Yes. The default “Today’s Hadith” view is calculated from the day of the year, so everyone visiting on the same calendar day sees the same hadith. Browsing by theme lets you look at any other entry immediately.

Can I use this Hadith of the Day tool for teaching or social media?

Yes β€” the Copy and Download buttons include the full reference, which makes it easy to share responsibly for lessons, khutbahs, or posts.

Why does this tool avoid AI-generated hadith text?

Hadith wording and authenticity grading require scholarly verification, not generation. This tool runs a local, rule-based engine over a fixed, pre-checked set of hadith β€” it never uses AI to write or paraphrase hadith text.

Make Hadith of the Day Part of Your Routine

Bookmark this page and come back daily β€” or explore every theme right now.

Read Today’s Hadith ↑
{ “@context”: “https://schema.org”, “@graph”: [ { “@type”: “WebApplication”, “name”: “Hadith of the Day”, “url”: “https://islamiceduhub.com/947-2/”, “applicationCategory”: “EducationalApplication”, “operatingSystem”: “Any (runs in browser)”, “offers”: { “@type”: “Offer”, “price”: “0”, “priceCurrency”: “USD” }, “description”: “A free Hadith of the Day generator that displays a new authentic hadith daily, sourced from Sahih al-Bukhari, Sahih Muslim, and Jami’ at-Tirmidhi with full references.” }, { “@type”: “BreadcrumbList”, “itemListElement”: [ { “@type”: “ListItem”, “position”: 1, “name”: “Home”, “item”: “https://islamiceduhub.com/” }, { “@type”: “ListItem”, “position”: 2, “name”: “Blog”, “item”: “https://islamiceduhub.com/blog/” }, { “@type”: “ListItem”, “position”: 3, “name”: “Hadith of the Day”, “item”: “https://islamiceduhub.com/947-2/” } ] }, { “@type”: “FAQPage”, “mainEntity”: [ { “@type”: “Question”, “name”: “What makes a Hadith of the Day authentic?”, “acceptedAnswer”: { “@type”: “Answer”, “text”: “An authentic (Sahih) hadith has an unbroken chain of trustworthy narrators back to the Prophet u25fe, verified by hadith scholars over centuries. This tool only includes hadith graded Sahih or Hasan, each labeled with its collection and reference number so you can check it yourself.” } }, { “@type”: “Question”, “name”: “Where do the hadith in this Hadith of the Day tool come from?”, “acceptedAnswer”: { “@type”: “Answer”, “text”: “Every hadith is sourced from Sahih al-Bukhari, Sahih Muslim, or Jami’ at-Tirmidhi, and each entry’s wording and reference number were checked against sunnah.com before being added to the tool.” } }, { “@type”: “Question”, “name”: “Does the Hadith of the Day change for everyone at the same time?”, “acceptedAnswer”: { “@type”: “Answer”, “text”: “Yes. The default “Today’s Hadith” view is calculated from the day of the year, so everyone visiting on the same calendar day sees the same hadith. Browsing by theme lets you look at any other entry immediately.” } }, { “@type”: “Question”, “name”: “Can I use this Hadith of the Day tool for teaching or social media?”, “acceptedAnswer”: { “@type”: “Answer”, “text”: “Yes u2014 the Copy and Download buttons include the full reference, which makes it easy to share responsibly for lessons, khutbahs, or posts.” } }, { “@type”: “Question”, “name”: “Why does this tool avoid AI-generated hadith text?”, “acceptedAnswer”: { “@type”: “Answer”, “text”: “Hadith wording and authenticity grading require scholarly verification, not generation. This tool runs a local, rule-based engine over a fixed, pre-checked set of hadith u2014 it never uses AI to write or paraphrase hadith text.” } } ] } ] } #hotd{ –hotd-ink:#241F16; –hotd-parchment:#F6EFDD; –hotd-parchment-2:#EFE4C8; –hotd-green:#14413B; –hotd-green-light:#1F5C52; –hotd-gold:#B8862F; –hotd-gold-light:#DDBD73; –hotd-font-display:’Cormorant Garamond’, Georgia, serif; –hotd-font-body:’Work Sans’, -apple-system, Helvetica, Arial, sans-serif; –hotd-font-mono:’IBM Plex Mono’, ‘Courier New’, monospace; font-family: var(–hotd-font-body); color: var(–hotd-ink); background: var(–hotd-parchment); line-height: 1.6; overflow-x: hidden; } #hotd *{ box-sizing: border-box; } #hotd img{ max-width:100%; height:auto; display:block; border-radius: 4px; } #hotd h1,#hotd h2,#hotd h3{ font-family: var(–hotd-font-display); color: var(–hotd-green); line-height:1.15; margin:0 0 .5em; } #hotd h1{ font-size: clamp(2.4rem, 5vw, 3.6rem); font-weight:600; } #hotd h2{ font-size: clamp(1.7rem, 3.2vw, 2.3rem); font-weight:600; } #hotd h3{ font-size: 1.25rem; font-weight:600; } #hotd p{ margin:0 0 1em; } #hotd section{ max-width: 1080px; margin: 0 auto; padding: 3.5rem 1.5rem; } #hotd a{ color: var(–hotd-green); text-decoration-color: var(–hotd-gold); text-underline-offset:3px; } #hotd a:hover{ color: var(–hotd-gold); } #hotd :focus-visible{ outline: 3px solid var(–hotd-gold); outline-offset: 2px; } /* Buttons */ #hotd .hotd-btn{ display:inline-flex; align-items:center; gap:.4em; font-family:var(–hotd-font-body); font-weight:600; font-size:.95rem; padding:.75em 1.4em; border-radius:999px; border:2px solid var(–hotd-green); cursor:pointer; text-decoration:none; transition: transform .15s ease, background .15s ease; } #hotd .hotd-btn-primary{ background: var(–hotd-green); color: var(–hotd-parchment); } #hotd .hotd-btn-primary:hover{ background: var(–hotd-green-light); transform: translateY(-1px); color:#fff; } #hotd .hotd-btn-ghost{ background: transparent; border-color: var(–hotd-gold); color: var(–hotd-green); } #hotd .hotd-btn-ghost:hover{ background: var(–hotd-gold); color: var(–hotd-green); transform: translateY(-1px); } /* ———- HERO ———- */ #hotd .hotd-hero{ max-width:1200px; display:grid; grid-template-columns: 1.1fr .9fr; gap: 2.5rem; align-items:center; padding-top: 3rem; } #hotd .hotd-eyebrow{ font-family: var(–hotd-font-mono); text-transform:uppercase; letter-spacing:.08em; font-size:.75rem; color: var(–hotd-gold); margin-bottom:.75em; } #hotd .hotd-value-prop{ font-size:1.15rem; max-width: 46ch; } #hotd .hotd-badges{ display:flex; flex-wrap:wrap; gap:.5rem; margin: 1.25rem 0; } #hotd .hotd-badge{ font-size:.8rem; background: var(–hotd-parchment-2); border:1px solid var(–hotd-gold-light); padding:.4em .8em; border-radius:999px; white-space:nowrap; } #hotd .hotd-trust-line{ font-size:.85rem; color:#5A503C; font-style:italic; } #hotd .hotd-hero-image .hotd-frame{ position:relative; padding:14px; background: linear-gradient(135deg, var(–hotd-gold-light), var(–hotd-gold)); border-radius: 10px; } #hotd .hotd-hero-image img{ border-radius:6px; border:3px solid var(–hotd-parchment); } /* ———- TOOL ———- */ #hotd .hotd-tool{ max-width:1200px; } #hotd .hotd-section-intro{ max-width:68ch; } #hotd .hotd-tool-grid{ display:grid; grid-template-columns: 240px 1fr; gap: 2rem; margin-top:2rem; align-items:start; } #hotd .hotd-shelf{ background: var(–hotd-green); border-radius:10px; padding:1.25rem 1rem; position:sticky; top:1rem; } #hotd .hotd-shelf-label{ color: var(–hotd-gold-light); font-family:var(–hotd-font-mono); font-size:.7rem; text-transform:uppercase; letter-spacing:.08em; margin-bottom:.75em; } #hotd .hotd-shelf-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:.4rem; } #hotd .hotd-tab{ width:100%; text-align:left; background: var(–hotd-green-light); color: var(–hotd-parchment); border:none; border-left:4px solid transparent; padding:.6em .7em; font-family:var(–hotd-font-body); font-size:.85rem; border-radius:4px; cursor:pointer; } #hotd .hotd-tab:hover{ border-left-color: var(–hotd-gold-light); } #hotd .hotd-tab[aria-pressed=”true”]{ background: var(–hotd-gold); color: var(–hotd-green); border-left-color: var(–hotd-green); font-weight:600; } /* Calendar-leaf card (signature element) */ #hotd .hotd-leaf-wrap{ perspective: 1000px; } #hotd .hotd-leaf{ position:relative; background:#fffdf7; border:1px solid var(–hotd-gold-light); border-radius: 4px 4px 14px 14px; padding: 2.5rem 2rem 2rem; box-shadow: 0 18px 40px -20px rgba(20,65,59,.45); clip-path: polygon(0 0,4% 3%,8% 0,12% 3%,16% 0,20% 3%,24% 0,28% 3%,32% 0,36% 3%,40% 0,44% 3%,48% 0,52% 3%,56% 0,60% 3%,64% 0,68% 3%,72% 0,76% 3%,80% 0,84% 3%,88% 0,92% 3%,96% 0,100% 0,100% 100%,0 100%); } #hotd .hotd-leaf-date{ font-family: var(–hotd-font-mono); font-size:.85rem; letter-spacing:.06em; color: var(–hotd-green); text-transform:uppercase; margin-bottom:1rem; } #hotd .hotd-stamp{ position:absolute; top:1.6rem; right:1.6rem; width:76px; height:76px; border-radius:50%; border:2.5px dashed var(–hotd-gold); color: var(–hotd-gold); font-family:var(–hotd-font-mono); font-size:.72rem; text-transform:uppercase; letter-spacing:.05em; display:flex; align-items:center; justify-content:center; text-align:center; transform: rotate(-8deg); } #hotd .hotd-theme-tag{ display:inline-block; font-family:var(–hotd-font-mono); font-size:.7rem; text-transform:uppercase; letter-spacing:.08em; color:#fff; background: var(–hotd-green); padding:.3em .7em; border-radius:4px; margin-bottom:1rem; } #hotd .hotd-text{ font-family: var(–hotd-font-display); font-size: 1.6rem; font-style:italic; color: var(–hotd-ink); margin: 0 0 1rem; padding:0 0 0 1rem; border-left: 3px solid var(–hotd-gold); max-width: 55ch; } #hotd .hotd-ref{ font-family: var(–hotd-font-mono); font-size:.85rem; color: var(–hotd-green); margin-bottom:1rem; } #hotd .hotd-reflection{ font-size:.95rem; color:#5A503C; max-width: 60ch; } #hotd .hotd-actions{ display:flex; flex-wrap:wrap; gap:.6rem; margin-top:1.5rem; padding-top:1.25rem; border-top:1px dashed var(–hotd-gold-light); } #hotd .hotd-actions .hotd-btn{ padding:.55em 1.1em; font-size:.85rem; } #hotd .hotd-copy-confirm{ font-size:.8rem; color: var(–hotd-green); font-weight:600; min-height:1.2em; margin:.5em 0 0; } /* ———- WHAT IS ———- */ #hotd .hotd-what-is{ max-width:1200px; display:grid; grid-template-columns:1fr 1fr; gap:2.5rem; align-items:center; background: var(–hotd-parchment-2); border-radius:16px; } /* ———- HOW ———- */ #hotd .hotd-steps{ max-width:70ch; padding-left:1.2rem; margin-bottom:2rem; } #hotd .hotd-steps li{ margin-bottom:1em; } #hotd .hotd-diagram{ max-width:640px; margin:0 auto; } /* ———- CHECKLIST ———- */ #hotd .hotd-check-list{ list-style:none; padding:0; max-width:60ch; } #hotd .hotd-check-list li{ padding:.5em 0; border-bottom:1px dashed var(–hotd-gold-light); } /* ———- TABLE ———- */ #hotd .hotd-table{ width:100%; border-collapse:collapse; max-width:70ch; background:#fff; border-radius:8px; overflow:hidden; } #hotd .hotd-table th, #hotd .hotd-table td{ text-align:left; padding:.8em 1em; border-bottom:1px solid var(–hotd-parchment-2); } #hotd .hotd-table th{ background: var(–hotd-parchment-2); width:34%; font-family:var(–hotd-font-mono); font-size:.8rem; text-transform:uppercase; letter-spacing:.04em; color:var(–hotd-green); } /* ———- AUDIENCE ———- */ #hotd .hotd-audience-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:1.25rem; } #hotd .hotd-audience-card{ background:#fff; border:1px solid var(–hotd-parchment-2); border-top:4px solid var(–hotd-gold); border-radius:8px; padding:1.4rem; } /* ———- LISTS ———- */ #hotd .hotd-practices-list, #hotd .hotd-mistakes-list{ padding-left:1.2rem; max-width:70ch; } #hotd .hotd-practices-list li, #hotd .hotd-mistakes-list li{ margin-bottom:.9em; } /* ———- FAQ ———- */ #hotd .hotd-faq-item{ border-bottom:1px solid var(–hotd-parchment-2); padding:1.25rem 0; } #hotd .hotd-faq-item h3{ margin-bottom:.4em; } /* ———- RELATED ———- */ #hotd .hotd-related-list{ list-style:none; padding:0; } #hotd .hotd-related-list li{ padding:.6em 0; border-bottom:1px dashed var(–hotd-gold-light); } /* ———- CTA ———- */ #hotd .hotd-cta{ text-align:center; background: var(–hotd-green); border-radius:16px; color: var(–hotd-parchment); max-width:1200px; } #hotd .hotd-cta h2{ color:#fff; } #hotd .hotd-cta .hotd-btn-primary{ background: var(–hotd-gold); border-color: var(–hotd-gold); color: var(–hotd-green); font-weight:700; } #hotd .hotd-cta .hotd-btn-primary:hover{ background: var(–hotd-gold-light); } /* ———- RESPONSIVE ———- */ @media (max-width:760px){ #hotd .hotd-hero{ grid-template-columns:1fr; } #hotd .hotd-tool-grid{ grid-template-columns:1fr; } #hotd .hotd-shelf{ position:static; } #hotd .hotd-shelf-list{ flex-direction:row; flex-wrap:wrap; } #hotd .hotd-tab{ width:auto; } #hotd .hotd-what-is{ grid-template-columns:1fr; } #hotd .hotd-audience-grid{ grid-template-columns:1fr 1fr; } #hotd .hotd-text{ font-size:1.3rem; } #hotd .hotd-stamp{ width:60px; height:60px; font-size:.62rem; top:1rem; right:1rem; } } @media (max-width:480px){ #hotd .hotd-audience-grid{ grid-template-columns:1fr; } } /* ———- PRINT ———- */ @media print{ #hotd .hotd-hero, #hotd .hotd-shelf, #hotd .hotd-actions, #hotd .hotd-what-is, #hotd .hotd-how, #hotd .hotd-checklist, #hotd .hotd-example, #hotd .hotd-audience, #hotd .hotd-best-practices, #hotd .hotd-mistakes, #hotd .hotd-faq, #hotd .hotd-related, #hotd .hotd-cta{ display:none; } #hotd .hotd-leaf{ box-shadow:none; clip-path:none; border:1px solid #999; } } (function(){ “use strict”; // Fixed, pre-verified local hadith bank β€” every entry checked against // sunnah.com before being added. No AI generation happens at runtime. var HADITH_BANK = [ { theme: “Intention & Sincerity”, narrator: “Umar ibn al-Khattab”, text: “Actions are judged by intentions, and every person will get the reward according to what he intended. So whoever emigrated for the sake of Allah and His Messenger, his emigration is for Allah and His Messenger; but whoever emigrated for worldly gain or to marry a woman, his emigration is for whatever he emigrated for.”, collection: “Sahih al-Bukhari”, ref: “Hadith 1”, grade: “Sahih”, reflection: “Before you begin any task today, pause and ask what you’re really doing it for β€” intention shapes an action’s worth.” }, { theme: “Brotherhood & Love”, narrator: “Anas ibn Malik”, text: “None of you truly believes until he loves for his brother what he loves for himself.”, collection: “Sahih al-Bukhari”, ref: “Hadith 13”, grade: “Sahih”, reflection: “Genuine faith shows up in how readily you want good for other people, not only for yourself.” }, { theme: “Purity & Worship”, narrator: “Abu Malik al-Ash’ari”, text: “Cleanliness is half of faith, and ‘Al-hamdu lillah’ fills the scale, and ‘SubhanAllah’ and ‘Al-hamdu lillah’ fill up what is between the heavens and the earth, and prayer is a light, and charity is proof of faith, and patience is illumination, and the Qur’an is a proof for you or against you.”, collection: “Sahih Muslim”, ref: “Hadith 223”, grade: “Sahih”, reflection: “Physical and spiritual cleanliness are treated as two halves of one whole β€” small daily habits of purity carry real weight.” }, { theme: “Speech & Silence”, narrator: “Abu Hurairah”, text: “Whoever believes in Allah and the Last Day should speak good or remain silent.”, collection: “Sahih al-Bukhari”, ref: “Hadith 6136 (also narrated in Sahih Muslim)”, grade: “Sahih”, reflection: “A simple daily filter for your words: if it isn’t kind or useful, it may be better left unsaid.” }, { theme: “Character & Manners”, narrator: “Abdullah ibn Amr”, text: “The best among you are those who have the best manners and character.”, collection: “Sahih al-Bukhari”, ref: “Hadith 6029”, grade: “Sahih”, reflection: “Excellence in Islam is measured as much by character as by ritual β€” how you treat people is itself an act of worship.” }, { theme: “Patience & Self-Control”, narrator: “Abu Hurairah”, text: “The strong person is not the one who overcomes people through his strength, but the one who controls himself while in anger.”, collection: “Sahih al-Bukhari”, ref: “Hadith 6114 (also Sahih Muslim 2609)”, grade: “Sahih”, reflection: “The next time something makes you angry, remember that restraint in that moment is its own kind of strength.” }, { theme: “Kindness & Restraint”, narrator: “Abdullah ibn Amr”, text: “A Muslim is the one from whose tongue and hand other people are safe, and an emigrant is the one who gives up what Allah has forbidden.”, collection: “Sahih al-Bukhari”, ref: “Hadith 10”, grade: “Sahih”, reflection: “A simple daily bar: did the people around you feel safe from your words and your hands today?” }, { theme: “Charity & Generosity”, narrator: “Abu Dharr”, text: “Your smiling in the face of your brother is charity, commanding good and forbidding evil is charity, guiding a man lost in the land is charity, and removing a harmful object such as a stone or thorn from the road is charity.”, collection: “Jami’ at-Tirmidhi”, ref: “Hadith 1956”, grade: “Hasan”, reflection: “Charity in Islam is far broader than money β€” a smile, a warning, or clearing a hazard from someone’s path all count.” }, { theme: “Seeking Knowledge”, narrator: “Abu Hurairah”, text: “Whoever travels a path in search of knowledge, Allah will make easy for him a path to Paradise.”, collection: “Sahih Muslim”, ref: “Hadith 2699”, grade: “Sahih”, reflection: “Every small effort to learn something true about your faith today is, according to this hadith, never wasted.” } ]; var els = { tabs: document.getElementById(‘hotd-tabs’), date: document.getElementById(‘hotd-date’), stamp: document.getElementById(‘hotd-stamp’), theme: document.getElementById(‘hotd-theme’), text: document.getElementById(‘hotd-hadith-text’), ref: document.getElementById(‘hotd-ref’), reflection: document.getElementById(‘hotd-reflection’), another: document.getElementById(‘hotd-another’), copyBtn: document.getElementById(‘hotd-copy’), printBtn: document.getElementById(‘hotd-print’), downloadBtn: document.getElementById(‘hotd-download’), confirm: document.getElementById(‘hotd-copy-confirm’) }; var currentIndex = 0; function dayOfYearIndex(){ var now = new Date(); var start = new Date(now.getFullYear(), 0, 0); var diff = now – start; var oneDay = 1000 * 60 * 60 * 24; var dayNum = Math.floor(diff / oneDay); return dayNum % HADITH_BANK.length; } function formatDate(){ var now = new Date(); return now.toLocaleDateString(undefined, { weekday:’long’, year:’numeric’, month:’long’, day:’numeric’ }); } function render(index){ currentIndex = index; var h = HADITH_BANK[index]; els.theme.textContent = h.theme; els.text.textContent = ‘”‘ + h.text + ‘”‘; els.ref.textContent = h.narrator + ‘ β€” ‘ + h.collection + ‘, ‘ + h.ref + ‘ (‘ + h.grade + ‘)’; els.reflection.textContent = h.reflection; els.stamp.textContent = h.grade; els.confirm.textContent = ”; var tabButtons = els.tabs.querySelectorAll(‘.hotd-tab’); tabButtons.forEach(function(btn, i){ btn.setAttribute(‘aria-pressed’, i === index ? ‘true’ : ‘false’); }); } function buildTabs(){ HADITH_BANK.forEach(function(h, i){ var li = document.createElement(‘li’); var btn = document.createElement(‘button’); btn.type = ‘button’; btn.className = ‘hotd-tab’; btn.textContent = h.theme; btn.setAttribute(‘aria-pressed’, ‘false’); btn.addEventListener(‘click’, function(){ render(i); }); li.appendChild(btn); els.tabs.appendChild(li); }); } function plainTextOutput(){ var h = HADITH_BANK[currentIndex]; return ‘Hadith of the Day β€” ‘ + h.theme + ‘nn”‘ + h.text + ‘”nn’ + ‘Narrator: ‘ + h.narrator + ‘n’ + ‘Source: ‘ + h.collection + ‘, ‘ + h.ref + ‘n’ + ‘Grade: ‘ + h.grade + ‘nn’ + ‘Reflection: ‘ + h.reflection + ‘nn’ + ‘Verify at: https://sunnah.comn’ + ‘Via islamiceduhub.com/hadith-of-the-day/’; } els.another.addEventListener(‘click’, function(){ var next = currentIndex; if (HADITH_BANK.length > 1){ while (next === currentIndex){ next = Math.floor(Math.random() * HADITH_BANK.length); } } render(next); }); els.copyBtn.addEventListener(‘click’, function(){ var text = plainTextOutput(); if (navigator.clipboard && navigator.clipboard.writeText){ navigator.clipboard.writeText(text).then(function(){ els.confirm.textContent = ‘Copied to clipboard.’; }).catch(function(){ els.confirm.textContent = ‘Could not copy β€” please select and copy manually.’; }); } else { els.confirm.textContent = ‘Copy not supported in this browser.’; } }); els.printBtn.addEventListener(‘click’, function(){ window.print(); }); els.downloadBtn.addEventListener(‘click’, function(){ var text = plainTextOutput(); var blob = new Blob([text], { type: ‘text/plain’ }); var url = URL.createObjectURL(blob); var a = document.createElement(‘a’); a.href = url; a.download = ‘hadith-of-the-day.txt’; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }); buildTabs(); els.date.textContent = formatDate(); render(dayOfYearIndex()); })();
Scroll to Top