RubyRuby V4 Misc API Reference for Realtime Apps


These docs are for PubNub 4.0 for Ruby which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.0 for Ruby.

If you have questions about the PubNub for Ruby SDK, please contact us at

This function will return a 17 digit precision Unix epoch.
The timetoken is constructed using the following algorithm:
timetoken = (Unix epoch time in seconds) * 10000000
To convert back and forth between current time, and a timetoken
now =
2012-11-02 14:27:11 -0700

timetoken = now.to_f * 10000000
13518916319742640 / 10000000)
2012-11-02 14:27:11 -0700
To fetch Time you can use the following method(s) in Ruby V4 SDK
  1. ParameterTypeRequiredDescription

    Default false. Method will be executed asynchronously and will return future, to get it's value you can use value method. If set to true, method will return array of envelopes (even if there's only one envelope).

    For sync methods Envelope object will be returned.

    callbackLambda accepting one parameterOptional

    Callback that will be called for each envelope.

    For async methods future will be returned, to retrieve value Envelope object you have to call value method (thread will be locked until the value is returned).

pubnub.time do |envelope|
    puts envelope.timetoken
The time() function returns a string timetoken in the following format: