I have requirement, where I need to fetch the local/client timezone offset and show the stored db time in local /client timezone and use it in another callback returned to UI.
How can i convert the below Javascript code which is in clientside_callback to the regular callback as show in below.
app.clientside_callback(
“”"
function(id) {
const local_date_str = new Date().toLocaleString();
return “The current date and time is: " + local_date_str
}
“””,
Output(‘date-time-title’, ‘children’),
Input(‘date-time-title’, ‘id’),
)
@app.callback(
Output(“DB_time”, “children”),
Input(“local_time_zone”, “n_clicks”)
)
def return_db_time_according_to_local_timezone(_):
“”"
I would like to show the time which is stored in DB
to the local time zone in UI
“”"
pass
I think the easiest way would be to send the data from the server not to a UI element, but to a dcc.Store that the clientside picks up and converts to local time.