How to parse ZendGData Picasa GPhotoTimestamps in PHP

So, i'm having a lot of trouble with this little piece of code. An example timestamp is this: '1278509422000'.. the problem is that it comes in as a string and I have to convert it somehow. I know about the problem with milliseconds and have tried dividing by a 1000 and much more (intval/floatval) but it just will not become a correct datetime value.


$gp = new Zend_Gdata_Photos(Zend_Gdata_AuthSub::getHttpClient($data->token), "Bla");
try {
    $userFeed = $gp->getUserFeed("default");
    foreach ($userFeed as $userEntry) {
        $album = $userEntry->getGphotoName();
        try {
            $query = $gp->newAlbumQuery();
            $albumFeed = $gp->getAlbumFeed($query);
            foreach ($albumFeed as $photo) {
                $time = date('Y-m-d H:m:s', $photo->getGphotoTimestamp());
        } catch(Exception $e) {
} catch(Exception $e) {


Ok.. So as it turns out, ZendGData is very very object oriented and the function getGphotoTimestamp() returns an object instead of and timestamp. I did not notice this because of the out-of-the way place the code has in the project (in a gearman job) and the fact that the object implements a __toString() which returns the string rep of the timestamp! Using floatval( strval( ... ) ) did the trick!

$time = date('Y-m-d H:m:s', intval($photo->getGphotoTimestamp())/1000);

The following code worked!! cheers...

$date_and_time = date('Y-m-d H:m:s', floatval(strval($entry->getGphotoTimestamp();)/1000));

Happy Coding .. :)

Need Your Help

FIPS Certification for Android & iPhone

iphone android cryptography fips

Does anyone know the name of the cryptography libraries come with iPhone & Android SDKs ? I don't mean the name of the classes, functions etc. but the name of the provider and/or the library it...

pyqt QTreeWidget setColumnWidth not working

python qt pyqt qtreewidget

So I saw some similar questions posted about this, but maybe I'm just not smart enough to apply it to my situation. In the following example, the only column that seems to be affected by the