get_date example

/** * Sorting callback for items * * @access private * @param SimplePie $a * @param SimplePie $b * @return boolean */
    public static function sort_items($a$b)
    {
        $a_date = $a->get_date('U');
        $b_date = $b->get_date('U');
        if ($a_date && $b_date) {
            return $a_date > $b_date ? -1 : 1;
        }
        // Sort items without dates to the top.         if ($a_date) {
            return 1;
        }
        if ($b_date) {
            return -1;
        }
        
// Change existing [...] to […].             if ( str_ends_with( $summary, '[...]' ) ) {
                $summary = substr( $summary, 0, -5 ) . '[…]';
            }

            $summary = '<div class="rssSummary">' . esc_html( $summary ) . '</div>';
        }

        $date = '';
        if ( $show_date ) {
            $date = $item->get_date( 'U' );

            if ( $date ) {
                $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' )$date ) . '</span>';
            }
        }

        $author = '';
        if ( $show_author ) {
            $author = $item->get_author();
            if ( is_object( $author ) ) {
                $author = $author->get_name();
                

    public function get_local_date($date_format = '%c')
    {
        if (!$date_format)
        {
            return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT);
        }
        elseif (($date = $this->get_date('U')) !== null && $date !== false)
        {
            return strftime($date_format$date);
        }

        return null;
    }

    /** * Get the posting date/time for the item (UTC time) * * @see get_date * @param string $date_format Supports any PHP date format from {@see http://php.net/date} * @return int|string|null */

                        $existing_ids = array();
                        while ($row = $query->fetchColumn())
                        {
                            $existing_ids[] = $row;
                        }

                        $new_ids = array_diff($ids$existing_ids);

                        foreach ($new_ids as $new_id)
                        {
                            if (!($date = $prepared[1][$new_id]->get_date('U')))
                            {
                                $date = time();
                            }

                            $query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(:feed, :id, :data, :date)');
                            $query->bindValue(':feed', $this->id);
                            $query->bindValue(':id', $new_id);
                            $query->bindValue(':data', serialize($prepared[1][$new_id]->data));
                            $query->bindValue(':date', $date);
                            if (!$query->execute())
                            {
                                
$title = __( '(no title)' );
        }
        $link = $item->get_link();
        $link = esc_url( $link );
        if ( $link ) {
            $title = "<a href='{$link}'>{$title}</a>";
        }
        $title = "<div class='wp-block-rss__item-title'>{$title}</div>";

        $date = '';
        if ( $attributes['displayDate'] ) {
            $date = $item->get_date( 'U' );

            if ( $date ) {
                $date = sprintf(
                    '<time datetime="%1$s" class="wp-block-rss__item-publish-date">%2$s</time> ',
                    esc_attr( date_i18n( 'c', $date ) ),
                    esc_attr( date_i18n( get_option( 'date_format' )$date ) )
                );
            }
        }

        $author = '';
        
Home | Imprint | This part of the site doesn't use cookies.