How should I do pagination with load history of real-time API?

I cannot understand this part of the real-time API document which is titled as Load History. I need to do pagination to implement and infinite list of messages in a group. I don’t understand the function of the second and fourth item in params array which are supposed to be date.

the document says this about the second param:

The NEWEST message timestamp date (or null) to only retrieve messages before this time. - this is used to do pagination

and this about the fourth param:

A date object - the date of the last time the client got data for the room

can anyone explain this to me?

For the first call just pass null in place of newest message timestamp and current timestamp as date object -

{
    "msg": "method",
    "method": "loadHistory",
    "id": "42",
    "params": [ "room-id", null, 50, { "$date": 1480377601 } ]
}

And after getting the response from the above API call. just save the timestamp of last message from messages list.
and then in next API call pass the saved timestamp as newest message timestamp -

{
    "msg": "method",
    "method": "loadHistory",
    "id": "42",
    "params": [ "room-id", savedTimestamp, 50, { "$date": 1480377601 } ]
}

And again save the last message timestamp from the message list you got from the above API call.