简体   繁体   中英

Access created_on from response object - get file action PODIO API

Hello folks I'm trying to access the created_on object using code below but it is not working, I'm getting incorrect date January 1, 1970 12:00 . Also tried

$item = PodioItem::get($item_id);
$file_id = "";
$created_on = "";
foreach ($item->files as $file) {
echo date('F j, Y h:i',strtotime($file->created_on))."<br>"; 
}

Below is the response object from print_r($file,true) , I can access the other object without any issue like $file->file_id, $file->link . What I'm trying to accomplish is store the created_on data in a variable then create a function to check and grab the latest date, then grab the file_id of it.

 PodioFile Object

 [__attributes:PodioObject:private] => Array
        (
            [file_id] => 464714088
            [link] => https://files.podio.com/464714088
            [perma_link] => 
            [thumbnail_link] => 
            [hosted_by] => podio
            [name] => KEjj4UQSUV.PDF
            [description] => 
            [mimetype] => application/pdf
            [size] => 785849
            [created_on] => 2017-12-08 23:03:36
            [rights] => Array
                (
                    [0] => download
                    [1] => view
                    [2] => delete
                    [3] => update
                )

 PodioFile Object
(
    [__attributes:PodioObject:private] => Array
        (
            [file_id] => 464716575
            [link] => https://files.podio.com/464716575
            [perma_link] => 
            [thumbnail_link] => 
            [hosted_by] => podio
            [name] => IiaCfJjwws.PDF
            [description] => 
            [mimetype] => application/pdf
            [size] => 785849
            [created_on] => 2017-12-08 23:15:30
            [rights] => Array
                (
                    [0] => download
                    [1] => view
                    [2] => delete
                    [3] => update
                )

PodioFile Object
(
    [__attributes:PodioObject:private] => Array
        (
            [file_id] => 464728331
            [link] => https://files.podio.com/464728331
            [perma_link] => 
            [thumbnail_link] => 
            [hosted_by] => podio
            [name] => g6cmAeUCiV.PDF
            [description] => 
            [mimetype] => application/pdf
            [size] => 785849
            [created_on] => 2017-12-08 23:49:15
            [rights] => Array
                (
                    [0] => download
                    [1] => view
                    [2] => delete
                    [3] => update
                )

Luckily found the answer on sample provided here - https://hotexamples.com/examples/-/PodioItem/filter/php-podioitem-filter-method-examples.html

date_format($file->created_on, 'Y/m/d H:i:s') did the trick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM