Powerpoint Countdown Timer Days Hours Minutes Seconds

1 view
Skip to first unread message

Malene Mederios

unread,
Aug 5, 2024, 7:48:36 AM8/5/24
to sanosara
Reactaka ReactJS) is a library that builds declarative and component-based user interfaces. With the inclusion of functional components and hooks, it is even more potent in reusability, better code organization, and data flow.

Web developers widely use React's standard hooks like useState, useEffect to manage state within the components. However, the practice of writing custom hooks seems to be a bit lesser. This article aims to explain the usages of the custom hook in a beginner-friendly manner. What could be better than learning it by developing a small but practical application?


We will create a countdown timer that will allow us to set an initial date and time to start the countdown. Once the date and time expire, it will show an expiry notice. The image below shows a working example of the app.


Please note we can do the entire countdown computation inside CountdownTimer or ShowCount components. But think about it, you may need this countdown calculation elsewhere in your app in the future. So, you shouldn't keep this tightly coupled with any components.


Let's welcome Custom Hook to solve the problem. We can isolate the countdown calculation in a custom hook called useCountdown. The custom hook accepts the initial date and time and returns the count of days, hours, minutes, and seconds in the interval of our choice(say, in every 1000 ms).


We see the useCountdown hook isolated from the component hierarchy. It supplies the required data to the component as needed. We also see the conditional rendering of ShowCounter and ExpiredNotice based on the counter value. We will determine the counter value based on the individual values of days, hours, minutes, and seconds.


You should have a browser tab opened automatically that runs the app @ :3000 URL. Please note the Create React App supports hot reloading. It means your app on the browser will update automatically when you make any changes to the project source code and save it.


The custom hooks are regular JavaScript functions to isolate a reusable component logic. The vital point to note here, we can share stateful logic between components without polluting the states. If you have been using React for a while now, you are making the same using patterns like Higher-Order Component, Render Props. Custom hooks are much more straightforward.


Take a closer look at the code above. It displays each of the values(days, hours, minutes, and seconds) using a component called DateTimeDisplay that we create now. But notice the props we pass to that component, especially the isDanger.


We can pass an expression using the isDanger props to style a particular display when the expression evaluates as true. For example, we want the days to turn red when the countdown reaches the last 3 days!


As you see, we are using the CountdownTimer component with a target date of three days from now. Please check the application in the browser. You should find the countdown is working. It doesn't look pleasant, but it works!


Here is an idea to extend the app further. You can use a Date-Time Picker to select a date and time of your choice and pass it to the countdown timer. Here is the suggested interface of the improved feature. Please give it a try.


The best way to learn React is by learning it practically with many simple but effective projects like the one we discussed here. You must recognize and plan the React concepts you can use in such projects. Look for opportunities to apply various React concepts into one. Do not make the projects a huge one at the same time.


Yes, the intention of this timer is to be as clean and simple as possible. As for changing the seconds, you can do that in the EXTENDED version or in the APP, which also has some other extra features. Tnx for your comment!


Hi, tnx for the comment and your feedback, it is valuable! For now we will not add extra functions, but we might use your suggestion next time. You can try using pause and simply continue when needed, and app also has sounds. Best


As for suggestion, we might implement it in the future. For now, maybe you can try this:

1. Add an extra monitor besides timer, there you can type something using word processor, or use some appropriate program for typing messages

2. Make timer smaller (use ESC to exit fullscreen display), adjust the size of timer and then use a the other part of the screen for messages to the presenter.


My only suggestion is that when the timer is reset with the Delete key that it would go back to the previously set time as almost all of our talks over two days were 15 minutes in length rather than the default 10 minutes. But it is easy to increase/decrease the time so that was only a very minor inconvenience.


I love the app for iOS! Any chance you will make a version compatible with the Amazon Fire HDX tablets? I see the app is available in the Amazon Appstore, but it only seems to be compatible with android OS.


Hi and thank you. I dont see a problem here, if I understand you correctly. On one monitor you will be running a full screen timer and on other (extended desktop) monitor, you have your presentation. It is allready being done like that on numerous TEDx presentations, as it was on ours. Best


I currently use the Apimac timer for my Anatomy lab exams because of one feature it has. It can be set to make a sound then automatically reset and start counting down again each time it finishes a countdown cycle. There are a number of things I do not like about the product, but that feature works and is necessary for my application. Does you timer have this feature? If so I would be interested.


I like the additional functions of the extended version. But was thinking that another feature that would be nice is having the color change (such as to yellow) with one minute remaining (or have that able to be modified). That way, the speaker will know when they are running short and must wrap things up.


Hi Steve, thanks for your comment and suggestion. The Nano version of the timer uses a very similar function to this, where the circle changes color not the numbers. This way it is visually more appealing. Best


Hello I was trying ti find a desktop background type count down timer which can be pushed to some 800 employees computer centrally. (The timer should be displayed on desktop background and will not affect users files, folders and other work. Pop up etc are sometimes annoying so was trying to find desktop background based timer.


Hi Mary, thank you so much for your kind comment! Yes, you get extra features in the PRO version you can get here: -timer-pc-mac/. You can purchase more than one license at a discount price. Thanks again and all the best.


Hi Igor. I just found you timer and it really looks impressive. However, I want to know whether it can be included in a Keynote presentation. I need the timer to appear on a slide for activities during class.


Hey Igor, Awesome timer! Thank you very much! I use it at our startup pitch events.

Is there a way to reset the timer to a previously set position => our pitchs are always 7 min. long. When I reset the timer it always goes back to 10 min.

Am I missing something? Thanks a lot!


Sorry for the late reply, missed the comment.

1) yes

2) to do this you will need another timer, where you can run multiple instances at the same time and it supports what you need: -timer-pro-sale

Hope this answered your questions. Best


Is there a way to have the countdown timer always display over any screen? I have minimized it to the way I need it but just want it to always be on top while I work. Thank you and this tool is absolutely amazing 10/10 would recommend.


We had a post on the forum recently asking how to create a timer in Excel, to record how long things took to happen on a model railroad. You can use the same code to time anything of course, like how long your code is taking to execute.


If I just try to write that out to a cell, Excel will try to display the integer part (123) as the number of days since Jan 1st 1900. Of course we want to show the number of days from now until our target date.


Thanks Matt. You need some event to start/stop the timer. You could write a macro that starts the timer when the workbook opens and then you could stop it after a set period of time or maybe at a set time.


Hi Catalin, thank you for your reply. I should start the timer and in the meantime edit in the cells but unfortunately I found that as soon as I edit in a cell the timer stops. Is there a way to solve this?

Thank you

Simone


I need to take the time I spent to complete a table in Excel. So the target is to start the timer, to complete the table by adding the proper numbers in the cells and finally to stop the time when I completed the table. Is it possible?

Thank you


For example my reference time is 10 minutes. One timer will count the elapsed time from 10 min. the other timer will tell me time remaining.

For example: reference time is 10 minutes, and 3 minutes have passed. Elapsed time will show 3 minutes. Remaining timer will show 7 minutes. Both values are positive.

I have downloaded several countdown timers, however, I have not solved the time remaining timer.


Excellent code that works well, but I do have a question. Say I wanted to start a timer at the start of a multi-day event. Would it be possible to start a timer on a document on my computer, save the document, exit the document, and email or send it to others or put it in a share drive, and have it constantly keep running and display the same accurate running timer across all other copies on other computers for other users? Any help would be greatly appreciated.


I am new to vba and have downloaded the your file. I am trying the above code to show the elapsed time. Upon adding the vba code at the end of the existing code, I am getting an error. I have added sheet2 to on the workbook.


Hello, Thank you for this beautiful elapsed time code. I am a beginner in vba macros and just learning by errors. I have used your elapsed time loop in the beginning of my script and the problem is that the code is stuck in the do While time loop and not executing the next lines of codes. Is there any way to run this loop while other codes are getting executed at the same time?

3a8082e126
Reply all
Reply to author
Forward
0 new messages