Utility Methods API for PHP SDK
The methods on this page are utility methods that don't fit into other categories.
Time
This function will return a 17 digit precision Unix epoch.
Algorithm constructing the timetoken
timetoken = (Unix epoch time in seconds) * 10000000
Example of creating a timetoken for a specific time and date:
08/19/2013 @ 9:20pm in UTC = 1376961606
timetoken = 1376961606 * 10000000
timetoken = 13769616060000000
Method(s)
To fetch Time
you can use the following method(s) in PHP SDK:
$pubnub->time()->sync();
This method doesn't take any argument.
Basic Usage
Get PubNub Timetoken
Reference code
This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.
<?php
// Include Composer autoloader (adjust path if needed)
require_once 'vendor/autoload.php';
use PubNub\PNConfiguration;
use PubNub\PubNub;
use PubNub\Exceptions\PubNubServerException;
// Create configuration with demo keys
$pnConfig = new PNConfiguration();
$pnConfig->setSubscribeKey("demo");
$pnConfig->setPublishKey("demo");
$pnConfig->setUserId("php-time-example-user");
show all 54 linesResponse
Method | Description |
---|---|
getTimetoken() Type: Integer | Returns a date representation of current timetoken. |