To display date in a specific format we can create a function to return the formatted date.
The following code will display the Created
and LastEdited
fields in the d-m-y
format:
private static $summary_fields = [
'CreatedDMY',
'LastEditedDMY',
];
private static $field_labels = [
'CreatedDMY' => 'Craido',
'LastEditedDMY' => 'Logado',
];
public function getCreatedDMY() {
return $this->dbObject('Created')->format('dd-MM-y');
}
public function getLastEditedDMY() {
return $this->dbObject('LastEdited')->format('dd-MM-y');
}
If we want to display the time as well we would change the format to dd-MM-y HH:mm:ss
public function getCreatedDMY() {
return $this->dbObject('Created')->format('dd-MM-y HH:mm:ss');
}
public function getLastEditedDMY() {
return $this->dbObject('LastEdited')->format('dd-MM-y HH:mm:ss');
}