How to echo Date Added of a file?

Permalink
Concrete5.8

I try this:
<?php echo $fileObj->getDateAdded();?>

Get error: Object of class DateTime could not be converted to string

Where to go from her?

siton
 
PineCreativeLabs replied on at Permalink Best Answer Reply
PineCreativeLabs
I am working on a new modal addon, where file info will be displayed. Below is how I did it.

$f = File::getByID($fileID);   
$fv = $f->getVersion();
$fileTitle = $fv->getTitle();
$fileDescription = $fv->getDescription();
$fileUrl = $fv->getRelativePath();
$fileSize = $fv->getSize();
$fileType = $fv->getType();
$fileAuthor = $fv->getAuthorName();
$dh = Loader::helper('date');
$fileDate = $dh->formatDateTime($f->getDateAdded('user'), false);


You'll notice this gets several other (built-in) attributes for the file. To actually render the date added, simply use this:
echo $fileDate

Hope that helps.
siton replied on at Permalink Reply
siton
Thanks! work nice :) (I use this data for schema.org markup! its boost the images on search results).