Html countdown clock that i can use on obsidian
- User
Html countdown clock that i can use on obsidian
- Assistant
Html countdown clock that i can use on obsidian
To create a countdown clock that you can use in Obsidian, you can make use of HTML and JavaScript. Obsidian allows you to embed HTML and JavaScript within notes using a plugin like "Obsidian HTML Reader" or by enabling custom scripts through community plugins. Below is a simple example of how you can create an HTML countdown clock:
Install Necessary Plugins: Make sure you have installed necessary plugins such as "Obsidian HTML Reader" or any other plugin that allows execution of HTML/JS within Obsidian.
Create Countdown HTML and JavaScript: Add the following HTML and JavaScript code to your Obsidian note:
<div id="countdown"></div>
<script>
// Set the date we're counting down to
const countDownDate = new Date("December 31, 2023 23:59:59").getTime();
// Update the count down every 1 second
const countdownFunction = setInterval(function() {
// Get today's date and time
const now = new Date().getTime();
// Find the distance between now and the count down date
const distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="countdown"
document.getElementById("countdown").innerHTML =
days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(countdownFunction);
document.getElementById("countdown").innerHTML = "EXPIRED";
}
}, 1000);
</script>
Customize the Countdown:
new Date("December 31, 2023 23:59:59") to the target date and time you prefer.Save and Preview: Once you have added the code to your note, save it. Use the preview feature in Obsidian to see the countdown in action.
Note: Since Obsidian is primarily a Markdown editor, native support for HTML requires specific plugins or workarounds. Ensure that JavaScript is allowed to run depending on your security settings and plugin capabilities. If full script execution isn't supported, consider adjusting your approach or seeking further assistance through community forums specific to Obsidian enhancements.
Not yet included in a published release.