Jan 06, 2020 in Drupal 8, Snippets

Some parts of custom entities seem different from nodes, but mostly they aren't. Small snippet for showing a created date of a custom entity in a controller.

$timestamp = $entity->get('created')->first()->getValue();
$formatted_date = date('j M Y', $timestamp['value']);