The code you are showing is wrong because [`DrupalDateTime::__construct()`][1] is expecting a string, while you are passing an integer, which is what [`Node::getCreatedTime()`][2] returns. Instead of `DrupalDateTime::__construct()`, you should use `DrupalDateTime::createFromTimestamp()`. $date = DrupalDateTime::createFromTimestamp($variables['node']->getCreatedTime(), 'UTC'); Since the static method also accept a `\DateTimeZone` object as second parameter, your code could be similar to the following one. if (isset($variables['node'])) { $date = DrupalDateTime::createFromTimestamp($variables['node']->getCreatedTime(), new \DateTimeZone('Asia/Tehran')); $variables['date'] = $date->format('Y/m/d'); } Since you seem interested to get strings in a specific language, you should also set the language code. if (isset($variables['node'])) { $date = DrupalDateTime::createFromTimestamp($variables['node']->getCreatedTime(), new \DateTimeZone('Asia/Tehran'), ['langcode' => 'the language code for the language you need']); $variables['date'] = $date->format('Y/m/d'); } [1]: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Datetime!DrupalDateTime.php/function/DrupalDateTime%3A%3A__construct/8 [2]: https://api.drupal.org/api/drupal/core!modules!node!src!Entity!Node.php/function/Node%3A%3AgetCreatedTime/8 [3]: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Datetime!DrupalDateTime.php/class/DrupalDateTime/8