time_since() public static method

Return a date in a relative format Based on: http://snippets.dzone.com/posts/show/5565
public static time_since ( $original ) : string
$original Date timestamp
return string
Example #1
0
 /**
  * @return array
  */
 public function populateItemTemplate(&$item)
 {
     $comments_count = $item->children('http://purl.org/rss/1.0/modules/slash/')->comments;
     $content = $item->children('http://purl.org/rss/1.0/modules/content/')->encoded;
     $tags = '';
     // pull tags out and make links of them
     foreach ($item->category as $t) {
         $tags .= '<li class="tag"><a href="' . $t->attributes() . htmlspecialchars($t) . '">' . htmlspecialchars($t) . '</a></li>';
     }
     if ($tags != '') {
         $tags = '<ul class="tags">' . $tags . '<li>Tagged:</li></ul>';
     }
     return array('link' => htmlspecialchars($item->link), 'title' => trim($item->title), 'date' => Pubwich::time_since($item->pubDate), 'comments_link' => $item->comments, 'comments_count' => $comments_count, 'description' => $item->description, 'content' => $content, 'author' => $item->author, 'tags' => $tags);
 }
Example #2
0
 /**
  * @return array
  */
 public function populateItemTemplate(&$item)
 {
     $link = $item->link->attributes()->href;
     $date = $item->published ? $item->published : $item->updated;
     return array('link' => htmlspecialchars($link), 'title' => trim($item->title), 'date' => Pubwich::time_since($date), 'absolute_date' => date($this->dateFormat, strtotime($date)), 'content' => $item->content);
 }
Example #3
0
 /**
  * @return array
  */
 public function populateItemTemplate(&$item)
 {
     // yep, this is actually book_edtion. Readernaut's creator Nathan Borror has been notified about this typo :)
     return array('id' => $item->reader_book_id, 'link' => $item->book_edtion->permalink, 'title' => $item->book_edtion->title, 'subtitle' => $item->book_edtion->subtitle, 'author' => $item->book_edtion->authors->author, 'image' => $item->book_edtion->covers->cover_small, 'image_medium' => $item->book_edtion->covers->cover_medium, 'image_large' => $item->book_edtion->covers->cover_large, 'size' => $this->size, 'created' => Pubwich::time_since($item->book_edtion->created), 'modified' => Pubwich::time_since($item->book_edtion->modified), 'isbn' => $item->book_edtion->isbn, 'body' => $item->body);
 }
Example #4
0
 /**
  * @return array
  */
 public function populateItemTemplate(&$item)
 {
     return array('link' => htmlspecialchars($item->url), 'title' => $item->title, 'date' => Pubwich::time_since($item->uploaded_date), 'caption' => $item->caption, 'duration' => $item->duration, 'width' => $item->width, 'height' => $item->height, 'image_small' => $item->thumbnail_small, 'image_medium' => $item->thumbnail_medium, 'image_large' => $item->thumbnail_large);
 }
Example #5
0
 public function populateItemTemplate(&$item)
 {
     return array('text' => $this->filterContent($item->text), 'date' => Pubwich::time_since($item->created_at), 'location' => $item->user->location, 'source' => $item->source);
 }
Example #6
0
 /**
  * @return array
  */
 public function populateItemTemplate(&$item)
 {
     $comments_count = $item->children('http://purl.org/rss/1.0/modules/slash/')->comments;
     $content = $item->children('http://purl.org/rss/1.0/modules/content/')->encoded;
     return array('link' => htmlspecialchars($item->link), 'title' => trim($item->title), 'date' => Pubwich::time_since($item->pubDate), 'comments_link' => $item->comments, 'comments_count' => $comments_count, 'description' => $item->description, 'content' => $content, 'author' => $item->author);
 }
Example #7
0
 public function populateItemTemplate(&$item)
 {
     return parent::populateItemTemplate($items) + array('title' => $item->Title, 'description' => $item->Description, 'link' => $item->URL, 'image' => $item->ThumbnailURL, 'thumbnail' => $item->ThumbnailSmallURL, 'embed' => $item->Embed, 'date' => Pubwich::time_since($item->Created), 'language' => $item->Language);
 }
Example #8
0
 public function processDataItem($item)
 {
     return array('text' => $item->text, 'status' => $this->filterContent($item->text), 'date' => Pubwich::time_since($item->created_at), 'timestamp' => strtotime($item->created_at));
 }
Example #9
0
 /**
  * @return array
  * @since 20110531
  */
 public function processDataItem($item)
 {
     // meta
     $link = $item->get_permalink();
     $author = ($author = $item->get_author()) ? trim($author->get_name()) : 'null';
     $category = ($category = $item->get_category()) ? trim($category->get_label()) : 'null';
     $date = $item->get_date('c');
     if (isset($this->dateFormat)) {
         $absolute_date = date($this->dateFormat, strtotime($date));
     } else {
         $absolute_date = null;
     }
     $timestamp = 0;
     $timestamp = strtotime($date);
     // content
     $summary = strip_tags(trim($item->get_description()), '<br>');
     $content = trim($item->get_content());
     $title = strip_tags(trim($item->get_title()));
     if (!$title) {
         $title = $summary ? $summary : $content;
     }
     $title = strip_tags(str_replace(array('<br>', '<br/>'), ' ', $title));
     // media
     $media = $item->get_enclosure();
     if ($media) {
         $media_url = $media->get_link();
         $media_thumbnail_url = $media->get_thumbnail();
         $media_extension = $media->get_extension();
         $media_type = explode('/', $media->get_real_type());
         $media_type[] = array(null);
         $media_type = ($media_type = trim($media_type[0])) ? $media_type : $media->get_medium();
         $media_caption = trim(strip_tags($media->get_description()));
         if (!$media_caption) {
             $media_caption = $media->get_caption();
             $media_caption = $media_caption ? trim(strip_tags($media->get_text())) : '';
         }
     } else {
         $media_url = null;
         $media_thumbnail_url = null;
         $media_extension = null;
         $media_type = null;
         $media_caption = null;
     }
     // comments TODO
     // compile array to return
     return array('link' => $link, 'author' => $author, 'category' => $category, 'date' => Pubwich::time_since($date), 'absolute_date' => $absolute_date, 'timestamp' => $timestamp, 'title' => $title, 'summary' => $summary, 'content' => $content, 'media_url' => $media_url, 'media_thumbnail_url' => $media_thumbnail_url, 'media_type' => $media_type, 'media_caption' => $media_caption);
 }
Example #10
0
 /**
  * @return array
  * @since 20120909
  */
 public function processDataItem($item)
 {
     return array('description' => $item->description, 'owner' => $item->user->login, 'link' => $item->html_url, 'public' => $item->public, 'date' => Pubwich::time_since($item->updated_at), 'timestamp' => strtotime($item->updated_at));
 }
Example #11
0
 /**
  * @return array
  */
 public function populateItemTemplate(&$item)
 {
     $public = $item->fork == 'true';
     return array('description' => $item->description, 'repo' => $item->repo, 'permalink' => sprintf('http://gist.github.com/%s', $item->repo), 'date' => Pubwich::time_since($item->{'created-at'}), 'owner' => $item->owner, 'files' => (array) $item->files->file);
 }
Example #12
0
 public function populateItemTemplate(&$item)
 {
     return array('date' => Pubwich::time_since($item->last_checkin_at), 'image' => $item->spot->image_url, 'name' => $item->spot->name, 'url' => $this->base . $item->spot->url, 'visits' => $item->checkins_count);
 }
Example #13
0
 /**
  * @return array
  */
 public function populateItemTemplate(&$item)
 {
     $link = $item->link->attributes()->href;
     return array('link' => htmlspecialchars($link), 'title' => trim($item->title), 'date' => $item->published ? Pubwich::time_since($item->published) : Pubwich::time_since($item->updated), 'content' => $item->content);
 }
Example #14
0
 public function populateItemTemplate($item)
 {
     return array('url' => $item->url, 'title' => $item->title, 'state' => $item->state, 'time_added' => Pubwich::time_since(strftime('%T', $item->time_added)), 'time_updated' => Pubwich::time_since(strftime('%T', $item->time_updated)));
 }