diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc
index 715b63d..e7f191c 100644
--- a/core/modules/comment/comment.tokens.inc
+++ b/core/modules/comment/comment.tokens.inc
@@ -5,6 +5,9 @@
  * Builds placeholder replacement tokens for comment-related data.
  */
 
+use Drupal\comment\Plugin\Core\Entity\Comment;
+use Drupal\node\Plugin\Core\Entity\Node;
+
 /**
  * Implements hook_token_info().
  */
@@ -115,8 +118,8 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
 
   $replacements = array();
 
-  if ($type == 'comment' && !empty($data['comment'])) {
-    $comment = $data['comment'];
+  if (!empty($data[$type]) && $data[$type] instanceof Comment) {
+    $comment = $data[$type];
 
     foreach ($tokens as $name => $original) {
       switch ($name) {
@@ -204,11 +207,13 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
     }
 
     if ($date_tokens = token_find_with_prefix($tokens, 'created')) {
-      $replacements += token_generate('date', $date_tokens, array('date' => $comment->created->value), $options);
+      $date = DateTime::createFromFormat('U', $comment->created->value);
+      $replacements += token_generate('date', $date_tokens, array('date' => $date), $options);
     }
 
     if ($date_tokens = token_find_with_prefix($tokens, 'changed')) {
-      $replacements += token_generate('date', $date_tokens, array('date' => $comment->changed->value), $options);
+      $date = DateTime::createFromFormat('U', $comment->changed->value);
+      $replacements += token_generate('date', $date_tokens, array('date' => $date), $options);
     }
 
     if (($parent_tokens = token_find_with_prefix($tokens, 'parent')) && $parent = $comment->pid->entity) {
@@ -219,8 +224,8 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
       $replacements += token_generate('user', $author_tokens, array('user' => $account), $options);
     }
   }
-  elseif ($type == 'node' & !empty($data['node'])) {
-    $node = $data['node'];
+  elseif (!empty($data[$type]) && $data[$type] instanceof Node) {
+    $node = $data[$type];
 
     foreach ($tokens as $name => $original) {
       switch($name) {
diff --git a/core/modules/file/file.tokens.inc b/core/modules/file/file.tokens.inc
new file mode 100644
index 0000000..d6db8b1
--- /dev/null
+++ b/core/modules/file/file.tokens.inc
@@ -0,0 +1,135 @@
+<?php
+
+/**
+ * @file
+ * Builds placeholder replacement tokens for files.
+ */
+
+use Drupal\file\Plugin\Core\Entity\File;
+
+/**
+ * Implements hook_token_info().
+ */
+function file_token_info() {
+  $types['file'] = array(
+    'name' => t("Files"),
+    'description' => t("Tokens related to uploaded files."),
+    'needs-data' => 'file',
+  );
+
+  // File related tokens.
+  $file['fid'] = array(
+    'name' => t("File ID"),
+    'description' => t("The unique ID of the uploaded file."),
+  );
+  $file['name'] = array(
+    'name' => t("File name"),
+    'description' => t("The name of the file on disk."),
+  );
+  $file['path'] = array(
+    'name' => t("Path"),
+    'description' => t("The location of the file relative to Drupal root."),
+  );
+  $file['mime'] = array(
+    'name' => t("MIME type"),
+    'description' => t("The MIME type of the file."),
+  );
+  $file['size'] = array(
+    'name' => t("File size"),
+    'description' => t("The size of the file."),
+  );
+  $file['url'] = array(
+    'name' => t("URL"),
+    'description' => t("The web-accessible URL for the file."),
+  );
+  $file['timestamp'] = array(
+    'name' => t("Timestamp"),
+    'description' => t("The date the file was most recently changed."),
+    'type' => 'date',
+  );
+  $file['owner'] = array(
+    'name' => t("Owner"),
+    'description' => t("The user who originally uploaded the file."),
+    'type' => 'user',
+  );
+
+  return array(
+    'types' => $types,
+    'tokens' => array(
+      'file' => $file,
+    ),
+  );
+}
+
+/**
+ * Implements hook_tokens().
+ */
+function file_tokens($type, $tokens, array $data = array(), array $options = array()) {
+  $url_options = array('absolute' => TRUE);
+  if (isset($options['langcode'])) {
+    $url_options['language'] = language_load($options['langcode']);
+    $langcode = $options['langcode'];
+  }
+  else {
+    $langcode = NULL;
+  }
+  $sanitize = !empty($options['sanitize']);
+
+  $replacements = array();
+
+  if (!empty($data[$type]) && $data[$type] instanceof File) {
+    $file = $data[$type];
+
+    foreach ($tokens as $name => $original) {
+      switch ($name) {
+        // Basic keys and values.
+        case 'fid':
+          $replacements[$original] = $file->fid;
+          break;
+
+        // Essential file data
+        case 'name':
+          $replacements[$original] = $sanitize ? check_plain($file->filename) : $file->filename;
+          break;
+
+        case 'path':
+          $replacements[$original] = $sanitize ? check_plain($file->uri) : $file->uri;
+          break;
+
+        case 'mime':
+          $replacements[$original] = $sanitize ? check_plain($file->filemime) : $file->filemime;
+          break;
+
+        case 'size':
+          $replacements[$original] = format_size($file->filesize);
+          break;
+
+        case 'url':
+          $replacements[$original] = $sanitize ? check_plain(file_create_url($file->uri)) : file_create_url($file->uri);
+          break;
+
+        // These tokens are default variations on the chained tokens handled below.
+        case 'timestamp':
+          $replacements[$original] = format_date($file->timestamp, 'medium', '', NULL, $langcode);
+          break;
+
+        case 'owner':
+          $account = user_load($file->uid);
+          $name = user_format_name($account);
+          $replacements[$original] = $sanitize ? check_plain($name) : $name;
+          break;
+      }
+    }
+
+    if ($date_tokens = token_find_with_prefix($tokens, 'timestamp')) {
+      $date = DateTime::createFromFormat('U', $file->timestamp);
+      $replacements += token_generate('date', $date_tokens, array('date' => $date), $options);
+    }
+
+    if (($owner_tokens = token_find_with_prefix($tokens, 'owner')) && $account = user_load($file->uid)) {
+      $replacements += token_generate('user', $owner_tokens, array('user' => $account), $options);
+    }
+  }
+
+  return $replacements;
+}
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc
index c882450..78056aa 100644
--- a/core/modules/node/node.tokens.inc
+++ b/core/modules/node/node.tokens.inc
@@ -5,7 +5,7 @@
  * Builds placeholder replacement tokens for node-related data.
  */
 
-
+use Drupal\node\Plugin\Core\Entity\Node;
 
 /**
  * Implements hook_token_info().
@@ -102,8 +102,8 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
 
   $replacements = array();
 
-  if ($type == 'node' && !empty($data['node'])) {
-    $node = $data['node'];
+  if (!empty($data[$type]) && $data[$type] instanceof Node) {
+    $node = $data[$type];
 
     foreach ($tokens as $name => $original) {
       switch ($name) {
@@ -203,11 +203,13 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
     }
 
     if ($created_tokens = token_find_with_prefix($tokens, 'created')) {
-      $replacements += token_generate('date', $created_tokens, array('date' => $node->created), $options);
+      $date = DateTime::createFromFormat('U', $node->created);
+      $replacements += token_generate('date', $created_tokens, array('date' => $date), $options);
     }
 
     if ($changed_tokens = token_find_with_prefix($tokens, 'changed')) {
-      $replacements += token_generate('date', $changed_tokens, array('date' => $node->changed), $options);
+      $date = DateTime::createFromFormat('U', $node->changed);
+      $replacements += token_generate('date', $changed_tokens, array('date' => $date), $options);
     }
   }
 
diff --git a/core/modules/statistics/statistics.tokens.inc b/core/modules/statistics/statistics.tokens.inc
index c2c8fc3..5a74c3d 100644
--- a/core/modules/statistics/statistics.tokens.inc
+++ b/core/modules/statistics/statistics.tokens.inc
@@ -5,6 +5,8 @@
  * Builds placeholder replacement tokens for node visitor statistics.
  */
 
+use Drupal\node\Plugin\Core\Entity\Node;
+
 /**
  * Implements hook_token_info().
  */
@@ -35,8 +37,8 @@ function statistics_tokens($type, $tokens, array $data = array(), array $options
   $url_options = array('absolute' => TRUE);
   $replacements = array();
 
-  if ($type == 'node' & !empty($data['node'])) {
-    $node = $data['node'];
+  if (!empty($data[$type]) && $data[$type] instanceof Node) {
+    $node = $data[$type];
 
     foreach ($tokens as $name => $original) {
       if ($name == 'total-count') {
@@ -55,7 +57,8 @@ function statistics_tokens($type, $tokens, array $data = array(), array $options
 
     if ($created_tokens = token_find_with_prefix($tokens, 'last-view')) {
       $statistics = statistics_get($node->nid);
-      $replacements += token_generate('date', $created_tokens, array('date' => $statistics['timestamp']), $options);
+      $date = DateTime::createFromFormat('U', $statistics['timestamp']);
+      $replacements += token_generate('date', $created_tokens, array('date' => $date), $options);
     }
   }
 
diff --git a/core/modules/system/system.tokens.inc b/core/modules/system/system.tokens.inc
index a5e7ad2..b474ee5 100644
--- a/core/modules/system/system.tokens.inc
+++ b/core/modules/system/system.tokens.inc
@@ -8,6 +8,8 @@
  * 'date' and 'file' tokens.
  */
 
+use Drupal\file\Plugin\Core\Entity\File;
+
 /**
  * Implements hook_token_info().
  */
@@ -20,11 +22,6 @@ function system_token_info() {
     'name' => t("Dates"),
     'description' => t("Tokens related to times and dates."),
   );
-  $types['file'] = array(
-    'name' => t("Files"),
-    'description' => t("Tokens related to uploaded files."),
-    'needs-data' => 'file',
-  );
 
   // Site-wide global tokens.
   $site['name'] = array(
@@ -78,49 +75,11 @@ function system_token_info() {
     'description' => t("A date in UNIX timestamp format (%date)", array('%date' => REQUEST_TIME)),
   );
 
-
-  // File related tokens.
-  $file['fid'] = array(
-    'name' => t("File ID"),
-    'description' => t("The unique ID of the uploaded file."),
-  );
-  $file['name'] = array(
-    'name' => t("File name"),
-    'description' => t("The name of the file on disk."),
-  );
-  $file['path'] = array(
-    'name' => t("Path"),
-    'description' => t("The location of the file relative to Drupal root."),
-  );
-  $file['mime'] = array(
-    'name' => t("MIME type"),
-    'description' => t("The MIME type of the file."),
-  );
-  $file['size'] = array(
-    'name' => t("File size"),
-    'description' => t("The size of the file."),
-  );
-  $file['url'] = array(
-    'name' => t("URL"),
-    'description' => t("The web-accessible URL for the file."),
-  );
-  $file['timestamp'] = array(
-    'name' => t("Timestamp"),
-    'description' => t("The date the file was most recently changed."),
-    'type' => 'date',
-  );
-  $file['owner'] = array(
-    'name' => t("Owner"),
-    'description' => t("The user who originally uploaded the file."),
-    'type' => 'user',
-  );
-
   return array(
     'types' => $types,
     'tokens' => array(
       'site' => $site,
       'date' => $date,
-      'file' => $file,
     ),
   );
 }
@@ -173,13 +132,8 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a
     }
   }
 
-  elseif ($type == 'date') {
-    if (empty($data['date'])) {
-      $date = REQUEST_TIME;
-    }
-    else {
-      $date = $data['date'];
-    }
+  elseif (!empty($data[$type]) && $data[$type] instanceof \DateTime) {
+    $date = $data[$type]->getTimestamp();
 
     foreach ($tokens as $name => $original) {
       switch ($name) {
@@ -212,57 +166,17 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a
     }
   }
 
-  elseif ($type == 'file' && !empty($data['file'])) {
-    $file = $data['file'];
-
-    foreach ($tokens as $name => $original) {
-      switch ($name) {
-        // Basic keys and values.
-        case 'fid':
-          $replacements[$original] = $file->fid;
-          break;
-
-        // Essential file data
-        case 'name':
-          $replacements[$original] = $sanitize ? check_plain($file->filename) : $file->filename;
-          break;
-
-        case 'path':
-          $replacements[$original] = $sanitize ? check_plain($file->uri) : $file->uri;
-          break;
-
-        case 'mime':
-          $replacements[$original] = $sanitize ? check_plain($file->filemime) : $file->filemime;
-          break;
-
-        case 'size':
-          $replacements[$original] = format_size($file->filesize);
-          break;
-
-        case 'url':
-          $replacements[$original] = $sanitize ? check_plain(file_create_url($file->uri)) : file_create_url($file->uri);
-          break;
-
-        // These tokens are default variations on the chained tokens handled below.
-        case 'timestamp':
-          $replacements[$original] = format_date($file->timestamp, 'medium', '', NULL, $langcode);
-          break;
-
-        case 'owner':
-          $account = user_load($file->uid);
-          $name = user_format_name($account);
-          $replacements[$original] = $sanitize ? check_plain($name) : $name;
-          break;
-      }
-    }
-
-    if ($date_tokens = token_find_with_prefix($tokens, 'timestamp')) {
-      $replacements += token_generate('date', $date_tokens, array('date' => $file->timestamp), $options);
-    }
+  // Support deprecated timestamp dates.
+  elseif ($type == 'date' && !empty($data['date']) && filter_var($data['date'], FILTER_VALIDATE_INT)) {
+    $date = DateTime::createFromFormat('U', $data['date']);
+    $replacements += token_generate('date', $tokens, array('date' => $date), $options);
+  }
 
-    if (($owner_tokens = token_find_with_prefix($tokens, 'owner')) && $account = user_load($file->uid)) {
-      $replacements += token_generate('user', $owner_tokens, array('user' => $account), $options);
-    }
+  // Current date tokens.
+  // @todo Rename to 'current-date' type.
+  if ($type == 'date' && empty($data['date'])) {
+    $date = new DateTime();
+    $replacements += token_generate('date', $tokens, array('date' => $date), $options);
   }
 
   return $replacements;
diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc
index 34099ce..ffc68db 100644
--- a/core/modules/taxonomy/taxonomy.tokens.inc
+++ b/core/modules/taxonomy/taxonomy.tokens.inc
@@ -5,6 +5,9 @@
  * Builds placeholder replacement tokens for taxonomy terms and vocabularies.
  */
 
+use Drupal\taxonomy\Plugin\Core\Entity\Term;
+use Drupal\taxonomy\Plugin\Core\Entity\Vocabulary;
+
 /**
  * Implements hook_token_info().
  */
@@ -92,8 +95,8 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options =
   $replacements = array();
   $sanitize = !empty($options['sanitize']);
 
-  if ($type == 'term' && !empty($data['term'])) {
-    $term = $data['term'];
+  if (!empty($data[$type]) && $data[$type] instanceof Term) {
+    $term = $data[$type];
 
     foreach ($tokens as $name => $original) {
       switch ($name) {
@@ -147,8 +150,8 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options =
     }
   }
 
-  elseif ($type == 'vocabulary' && !empty($data['vocabulary'])) {
-    $vocabulary = $data['vocabulary'];
+  elseif (!empty($data[$type]) && $data[$type] instanceof Vocabulary) {
+    $vocabulary = $data[$type];
 
     foreach ($tokens as $name => $original) {
       switch ($name) {
diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc
index bc37434..6857906 100644
--- a/core/modules/user/user.tokens.inc
+++ b/core/modules/user/user.tokens.inc
@@ -5,6 +5,8 @@
  * Builds placeholder replacement tokens for user-related data.
  */
 
+use Drupal\user\Plugin\Core\Entity\User;
+
 /**
  * Implements hook_token_info().
  */
@@ -74,8 +76,9 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr
 
   $replacements = array();
 
-  if ($type == 'user' && !empty($data['user'])) {
-    $account = $data['user'];
+  if (!empty($data[$type]) && $data[$type] instanceof User) {
+    $account = $data[$type];
+
     foreach ($tokens as $name => $original) {
       switch ($name) {
         // Basic user account information.
@@ -114,11 +117,13 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr
     }
 
     if ($login_tokens = token_find_with_prefix($tokens, 'last-login')) {
-      $replacements += token_generate('date', $login_tokens, array('date' => $account->login), $options);
+      $date = DateTime::createFromFormat('U', $account->login);
+      $replacements += token_generate('date', $login_tokens, array('date' => $date), $options);
     }
 
     if ($registered_tokens = token_find_with_prefix($tokens, 'created')) {
-      $replacements += token_generate('date', $registered_tokens, array('date' => $account->created), $options);
+      $date = DateTime::createFromFormat('U', $account->created);
+      $replacements += token_generate('date', $registered_tokens, array('date' => $date), $options);
     }
   }
 
diff --git a/core/modules/views/views.tokens.inc b/core/modules/views/views.tokens.inc
index 9ca541a..033f039 100644
--- a/core/modules/views/views.tokens.inc
+++ b/core/modules/views/views.tokens.inc
@@ -5,6 +5,8 @@
  * Token integration for the views module.
  */
 
+use Drupal\views\ViewExecutable;
+
 /**
  * Implements hook_token_info().
  */
@@ -76,8 +78,8 @@ function views_tokens($type, $tokens, array $data = array(), array $options = ar
 
   $replacements = array();
 
-  if ($type == 'view' && !empty($data['view'])) {
-    $view = $data['view'];
+  if (!empty($data[$type]) && $data[$type] instanceof ViewExecutable) {
+    $view = $data[$type];
 
     foreach ($tokens as $name => $original) {
       switch ($name) {
