Skip to content

Instantly share code, notes, and snippets.

@scalabl3
Last active February 23, 2022 05:54
Show Gist options
  • Save scalabl3/c2bb54301e0c34f89d7e to your computer and use it in GitHub Desktop.
Save scalabl3/c2bb54301e0c34f89d7e to your computer and use it in GitHub Desktop.
PubNub Timetoken <-> Epoch Timestamp Conversion
  1. PubNub timetoken:

14459765691299403

  1. Divide by 10000000 (becomes Epoch in seconds if you truncate):

1445976569.1299403

  1. Subtract 1.0 seconds:

1445976568.1299403

  1. Multiply by 10000000:

14459765681299403

**Formula: **

epoch_time = (original_timetoken / 10000000)
new_timetoken = ( epoch_time - 1.0 ) * 10000000
new_timetoken = original_timetoken - (seconds * 10000000)

14459765691299403 :: Original

14459765681299403 :: 1 Second Before

@vijay9711
Copy link

what is seconds?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment