I want display the current time in my shiny App. Therefore, I can use Sys.time()
function(input, output, session) {
output$currentTime <- renderText({
invalidateLater(1000, session)
paste("The current time is", Sys.time())
})
}
I am wondering if it is also possible to code a countdown timer depending on the current time for e.g. an upcoming event?
The following code should do (let's assume the event is only 4 mins ahead):
EventTime <- Sys.time() + 4*60
output$eventTimeRemaining <- renderText({
invalidateLater(1000, session)
paste("The time remaining for the Event:",
round(difftime(EventTime, Sys.time(), units='secs')), 'secs')
})
with the following output:
The time remaining for the Event: 226 secs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With