I've uploaded my R Shiny app (using shinyMobile package) to Google Cloud Run using a Dockerfile, and am finding that the date returned by f7DatePicker doesn't match the value on the widget itself. So if I put in 2021-08-02, the actual date it returns (looking at the 'input$x' value) is 2021-08-01, even though the date displayed on the widget is 2021-08-02.
HOWEVER, it appears that this only occurs for users in particular timezones. I'm currently in New Zealand, and am finding that this issue is occurring for the mobile app for NZ based users; however, when I try running the app on a server in the US (i.e. via Browserstack), the date is correctly returned. BUT when I run the app locally on my desktop (in New Zealand), I don't have this issue. So I'm not sure if the issue is at the server end or at the client end.
It's possible that the issue is caused by daylight savings - see this link - but my local server runs fine, so if this were the case, it would have to be the interaction between Cloud Run and mobile somehow.
Here's the code I'm using to calculate client_time and time_zone_offset (based on this link:)
Javascript:
HTML('<input type="text" id="client_time" name="client_time" style="display: none;"> '),
HTML('<input type="text" id="client_time_zone_offset" name="client_time_zone_offset" style="display: none;"> '),
tags$script('
$(function() {
var time_now = new Date()
$("input#client_time").val(time_now.getTime())
$("input#client_time_zone_offset").val(time_now.getTimezoneOffset())
});')
Shiny: (in server.r)
client_time <<- as.numeric(input$client_time) / 1000 # in s
time_zone_offset <<- as.numeric(input$client_time_zone_offset) * 60 # s from GMT
curr_datetime <<- as_datetime(client_time - time_zone_offset)
Any ideas what the issue could be?
Thanks a lot