How to pass dynamic variable from server to UI in shiny

I have a small application below in shiny

library(shiny)

ui <- fluidPage(
#htmlOutput("d"),
tags$p(id = 'g', class =  'newClass',  'This is a paragraph'),tags$p(id = "demo"),
tags$script(HTML("var tit = document.getElementById('g');tit.onclick = function (){document.getElementById('demo').innerHTML  = Date()}"))
)

server <- function(input, output, session) {

}

shinyApp(ui, server)

This application is using javascript. When the user clicks on the sentence, the date displays. But the date is passed in the UI section itself.

My question is, Can we not pass the variable from server to UI here? For example, we create Var1 <- Sys.Date() in server section. Now I need to pass Var1 to UI in place of Date(). Is it possible?