You are here

protected function Post::createDate in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  2. 8.2 modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  3. 8.3 modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  4. 8.4 modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  5. 8.5 modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  6. 8.6 modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  7. 8.7 modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  8. 8.8 modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  9. 10.3.x modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  10. 10.0.x modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  11. 10.1.x modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()
  12. 10.2.x modules/custom/social_demo/src/Plugin/DemoContent/Post.php \Drupal\social_demo\Plugin\DemoContent\Post::createDate()

Converts a date in the correct format.

Parameters

string $date_string: The date.

Return value

int|false Returns a timestamp on success, false otherwise.

1 call to Post::createDate()
Post::getEntry in modules/custom/social_demo/src/Plugin/DemoContent/Post.php
Makes an array with data of an entity.

File

modules/custom/social_demo/src/Plugin/DemoContent/Post.php, line 68

Class

Post
Post Plugin for demo content.

Namespace

Drupal\social_demo\Plugin\DemoContent

Code

protected function createDate($date_string) {
  if ($date_string === 'now') {
    return time();
  }

  // Split from delimiter.
  $timestamp = explode('|', $date_string);
  $date = strtotime($timestamp[0]);
  $date = date('Y-m-d', $date) . 'T' . $timestamp[1] . ':00';
  return strtotime($date);
}