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?

library(shiny)

ui <- fluidPage(
  tags$p(id = 'g', class =  'newClass',  'This is a paragraph, you can press with JS'),tags$p(id = "demo"),
  tags$script(HTML("var tit = document.getElementById('g');tit.onclick = function (){document.getElementById('demo').innerHTML  = Date()}")),
  hr(),
  actionLink(inputId = "btn_to_press1",label = "This is also a paragraph, but conventional shiny"),
  uiOutput("myout1"),
  hr(),
  actionLink(inputId = "btn_to_press2",label = "This is also a paragraph, but conventional shiny, destyling the link",
             style='all: unset;'),
  uiOutput("myout2")
)

server <- function(input, output, session) {
  
  
  get_my_time <- function(){
    format(Sys.time(), "%a %b %d %Y %H:%M:%S GMT%z (Greenwich Mean Time)")
  }
  
  output$myout1 <- renderUI({
    req(input$btn_to_press1 )
    get_my_time()
  })
  
  
  output$myout2 <- renderUI({
    req(input$btn_to_press2 )
      get_my_time()
  })
  
}

shinyApp(ui, server)