How to get ticks delta between server and browser clocks for accurate calculation

This is a bit of an advanced question that I’m hoping some card devs or advanced customizers might have some experience with.

I need an accurate (to the second) measurement of how long ago something was updated. The primary challenge is trying to compare “last_updated” with the browser’s clock because there is always a time offset between the server and the devices running the dashboard.

The card I’m customizing doesn’t support jinja, but it does support javascript. I found a way to asynchronously call the server to render jinja from javascript to get the server’s time, but being asynchronous I can’t fetch and then make a decision on the value in the next line of javascript. Synchronously fetching the server’s current time would be more useful, or even better would be a pre-calculated ticks offset between the server and the browser in the hass object I can access from javascript.

I have seen other cards have trouble with the time offset, such as when showing last_updated as an “ago” value, some of my devices will show a future value until the units are large enough to be less obvious (i.e., “in 20 seconds” instead of “5 seconds ago”). A standardized ticks offset might be a nice way to solve this challenge for many use-cases.

I am hoping someone has some ideas.