Sunil Bhawsar
Sunil Bhawsar

Reputation: 199

How to convert openfire offlineDate into the correct datetime in php

How can i get and convert the xmpp(openfire) Last Logout time in a 'Y-m-d H:i:s' format using php ?

offlineDate=001457169225070

I want to convert this offlineDate into 'Y-m-d H:i:s' format in php.

Please help me.Thanks in advance.

Upvotes: 2

Views: 525

Answers (1)

Halayem Anis
Halayem Anis

Reputation: 7795

This timestamp '1457169225070' computed by openfire represents the number of milliseconds since 1/1/1970. So, i convert it to the number of seconds and used date() function

<?php
    $timestamp = (int) (1457169225070/1000);
    print date('Y-m-d H:i:s', $timestamp);
?>

OUTPUT

2016-03-05 09:13:45

Upvotes: 0

Related Questions