我想在我闪亮的App中显示当前时间.因此,我可以使用Sys.time()
function(input, output, session) {
output$currentTime <- renderText({
invalidateLater(1000, session)
paste("The current time is", Sys.time())
})
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否也可以根据例如即将举行的活动的当前时间来编码倒数计时器?
下面的代码应该做(让我们假设事件只提前4分钟):
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')
})
Run Code Online (Sandbox Code Playgroud)
具有以下输出:
The time remaining for the Event: 226 secs
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1774 次 |
| 最近记录: |