9

We have a dataset in Firebase updated by multiple clients. We want to track the last modified on datetime of the dataset. We cannot rely on the client setting the modified on datetime as their local clock can be totally out of sync.

Is there a way I could have Firebase tag timestamp to a dataset based on its clock to track last modified on?

2 Answers 2

5

We're working on some features to support this at the moment, but we don't have a way to do this right now. Note, however, that the IDs created by "push()" are chronologically-ordered, and we compensate for client-side clock skew as best we can when we create them, so if all you're trying to do is make sure some writes to a list occur in order, you can do that with push().

I'd be interested in hearing how you'd like this feature to look. If you have a sec I'd appreciate an email to andrew at firebase...

Update: Firebase now supports setting server timestamps as well as accessing the server time directly on the client. See the documentation here: https://www.firebase.com/docs/managing-presence.html

3
  • 2
    Here's one easy option: firebasePath.setTimestamp() would set the value of that path to YOUR server's time.
    – oori
    Oct 26, 2012 at 23:59
  • @Andrew Lee I think feature suggested by oori would be very useful Apr 14, 2013 at 22:43
  • 4
    Link is confusing; it redirects to firebase.com/docs/web/guide/offline-capabilities.html, which has a Managing Presence section, but the relevant documentation is not in that section but the later Handling Latency section. The answer as a whole could also be cleaned up to remove the obsolete info and just include what's in the 'Update', perhaps with the most salient details from the docs. I'll tidy it up when I have a free moment; feel free to go ahead and do so first.
    – Mark Amery
    Mar 3, 2015 at 18:10
0

We're on the same boat... and I guess sooner or later, many firebase clients will have this issue, as it's a "new kind" of problem we never had to face in the old "client-server" days.

Out current solution (still in the making) is to estimate the time difference between the client and OUR server on initialization, and them compensate,
So - where we had x = new Date(),
it is now x = ourDateService.now()

our now() function simply does new Date() + diff

This works for us,as we don't need millisecond accuracy, and it's a single-page-app that loads once, so we can do this diff-check and initialize ourDateService on load, but this solution will not work for everybody (ofcourse, you can store it in the localstorage/cookie and revalidate every day or so).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.