BrowserStack API returns UTC timestamps but UI shows local time – unresolved timezone consistency
0 reputation · 07 May 2024, 15:10 UTC
0 reputation · 07 May 2024, 15:10 UTC
BrowserStack’s Automate API supplies start_time and end_time fields in UTC for all test sessions. In contrast, the web UI displays these timestamps converted to the viewer’s local time zone. When a test is scheduled, a timezone field can be supplied in the payload; the UI then attempts to adjust the session times accordingly. However, this parameter has no effect on on‑demand tests, leading to divergent time‑zone handling between test types.
The documentation does not clarify whether the timezone field is intended to override UTC globally or remain limited to scheduled tests. There is also no documented option for a default global time‑zone setting that would affect all API responses and UI displays.
timezone parameter be honored for on‑demand tests, and if not, what is the rationale behind this restriction?30275 reputation · 07 May 2024, 20:32 UTC
1. Should timezone be honored for on‑demand tests? No. The timezone payload field is documented to affect only scheduled (future‑run) sessions. On‑demand tests start immediately, so there is no scheduled start time for the API to adjust. Therefore the field is ignored for those tests.
2. Will BrowserStack introduce a global time‑zone setting? Currently there is no such option. The API always returns UTC, and the UI always converts to the viewer’s local zone. Any future global setting would need to be announced in release notes; until then, you must handle conversion yourself.
3. How can developers reliably convert UTC timestamps? Perform the conversion in your own code using a reliable time‑zone library (e.g., java.time.ZonedDateTime, moment-timezone, date-fns-tz, etc.). Store or present the converted value in the zone that matches your reporting or user‑experience requirements.
start_time and end_time in UTC, regardless of test type.timezone field in the API payload only applies to scheduled tests; it is ignored for on‑demand sessions.start_time (ISO‑8601 UTC).Instant utc = Instant.parse(startTimeStr);ZonedDateTime local = utc.atZone(ZoneId.of("America/New_York"));local.format(DateTimeFormatter.ofPattern("yyyy‑MM‑dd HH:mm:ss z")).Do you need to aggregate session times across multiple users or accounts in a single, fixed time zone (for reporting or dashboards) rather than relying on each viewer’s local time? Knowing this will determine whether you should implement a global conversion layer in your application.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.