How can I get node creation date? How can I get node creation date and convert it to custom format in my theme, I tried to make some operations on node date in "MyTheme.theme" file and in preprocess_node section.
Code for getting node created date.

$date = $variables['node']-&gt;getCreatedTime();
  // Here you can use drupal's format_date() function, or some custom PHP date formatting.
  $variables['date'] = \Drupal::service('date.formatter')-&gt;format($date, '$format');// enter date format in $format.