mysql2date example

/** * Converts a WordPress date string to an IXR_Date object. * * @param string $date Date string to convert. * @return IXR_Date IXR_Date object. */
    protected function _convert_date( $date ) {
        if ( '0000-00-00 00:00:00' === $date ) {
            return new IXR_Date( '00000000T00:00:00Z' );
        }
        return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) );
    }

    /** * Converts a WordPress GMT date string to an IXR_Date object. * * @param string $date_gmt WordPress GMT date string. * @param string $date Date string. * @return IXR_Date IXR_Date object. */
    protected function _convert_date_gmt( $date_gmt$date ) {
        if ( '0000-00-00 00:00:00' !== $date && '0000-00-00 00:00:00' === $date_gmt ) {
            

                $excerpt = wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );

                $is_sticky = is_sticky( $post->ID ) ? 1 : 0;
                ?> <item> <title><?php echo $title; ?></title> <link><?php the_permalink_rss(); ?></link> <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> <dc:creator><?php echo wxr_cdata( get_the_author_meta( 'login' ) ); ?></dc:creator> <guid isPermaLink="false"><?php the_guid(); ?></guid> <description></description> <content:encoded><?php echo $content; ?></content:encoded> <excerpt:encoded><?php echo $excerpt; ?></excerpt:encoded> <wp:post_id><?php echo (int) $post->ID; ?></wp:post_id> <wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date> <wp:post_date_gmt><?php echo wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt> <wp:post_modified><?php echo wxr_cdata( $post->post_modified ); ?></wp:post_modified> <wp:post_modified_gmt><?php echo wxr_cdata( $post->post_modified_gmt ); ?></wp:post_modified_gmt> <wp:comment_status><?php echo wxr_cdata( $post->comment_status ); ?></wp:comment_status> <wp:ping_status>
while ( have_posts() ) :
        the_post();
        ?> <item> <title><?php the_title_rss(); ?></title> <link><?php the_permalink_rss(); ?></link> <?php if ( get_comments_number() || comments_open() ) : ?> <comments><?php comments_link_feed(); ?></comments> <?php endif; ?> <dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator> <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> <?php the_category_rss( 'rss2' ); ?> <guid isPermaLink="false"><?php the_guid(); ?></guid> <?php if ( get_option( 'rss_use_excerpt' ) ) : ?> <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> <?php else : ?> <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> <?php $content = get_the_content_feed( 'rss2' ); ?> <?php if ( strlen( $content ) > 0 ) : ?> <content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded> <?php else : ?>
$sql = $wpdb->prepare(
        "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( $check_column = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1",
        $hour_ago,
        $user,
        $email
    );

    $lasttime = $wpdb->get_var( $sql );

    if ( $lasttime ) {
        $time_lastcomment = mysql2date( 'U', $lasttime, false );
        $time_newcomment  = mysql2date( 'U', $date, false );

        /** * Filters the comment flood status. * * @since 2.1.0 * * @param bool $bool Whether a comment flood is occurring. Default false. * @param int $time_lastcomment Timestamp of when the last comment was posted. * @param int $time_newcomment Timestamp of when the new comment was posted. */
        
$autosave    = false;
    $form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
} else {
    $autosave = wp_get_post_autosave( $post->ID );
}

$form_action  = 'editpost';
$nonce_action = 'update-post_' . $post->ID;
$form_extra  .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post->ID ) . "' />";

// Detect if there exists an autosave newer than the post and if that autosave is different than the post. if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
    foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
        if ( normalize_whitespace( $autosave->$autosave_field ) !== normalize_whitespace( $post->$autosave_field ) ) {
            $notice = sprintf(
                /* translators: %s: URL to view the autosave. */
                __( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ),
                get_edit_post_link( $autosave->ID )
            );
            break;
        }
    }
    // If this autosave isn't different from the current post, begone.
|| str_contains( $this->query_vars['feed'], 'comments-' )
                || ( empty( $this->query_vars['withoutcomments'] )
                    && ( ! empty( $this->query_vars['p'] )
                        || ! empty( $this->query_vars['name'] )
                        || ! empty( $this->query_vars['page_id'] )
                        || ! empty( $this->query_vars['pagename'] )
                        || ! empty( $this->query_vars['attachment'] )
                        || ! empty( $this->query_vars['attachment_id'] )
                    )
                )
            ) {
                $wp_last_modified_post    = mysql2date( $date_formatget_lastpostmodified( 'GMT' ), false );
                $wp_last_modified_comment = mysql2date( $date_formatget_lastcommentmodified( 'GMT' ), false );
                if ( strtotime( $wp_last_modified_post ) > strtotime( $wp_last_modified_comment ) ) {
                    $wp_last_modified = $wp_last_modified_post;
                } else {
                    $wp_last_modified = $wp_last_modified_comment;
                }
            } else {
                $wp_last_modified = mysql2date( $date_formatget_lastpostmodified( 'GMT' ), false );
            }

            if ( ! $wp_last_modified ) {
                
$post_title = the_title_attribute(
        array(
            'echo' => false,
            'post' => $post,
        )
    );

    if ( empty( $post_title ) ) {
        $post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' );
    }

    $date = mysql2date( get_option( 'date_format' )$post->post_date );

    $title = str_replace( '%title', $post_title$title );
    $title = str_replace( '%date', $date$title );

    $link  = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
    $link .= esc_attr( $title );
    $link .= "' href='" . get_permalink( $post ) . "' />\n";

    $adjacent = $previous ? 'previous' : 'next';

    /** * Filters the adjacent post relational link. * * The dynamic portion of the hook name, `$adjacent`, refers to the type * of adjacency, 'next' or 'previous'. * * Possible hook names include: * * - `next_post_rel_link` * - `previous_post_rel_link` * * @since 2.8.0 * * @param string $link The relational link. */
populate_roles_210();
    }

    if ( $wp_current_db_version < 3531 ) {
        // Give future posts a post_status of future.         $now = gmdate( 'Y-m-d H:i:59' );
        $wpdb->query( "UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'" );

        $posts = $wpdb->get_results( "SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'" );
        if ( ! empty( $posts ) ) {
            foreach ( $posts as $post ) {
                wp_schedule_single_event( mysql2date( 'U', $post->post_date, false ), 'publish_future_post', array( $post->ID ) );
            }
        }
    }
}

/** * Execute changes made in WordPress 2.3. * * @ignore * @since 2.3.0 * * @global int $wp_current_db_version The old (current) database version. * @global wpdb $wpdb WordPress database abstraction object. */

    public function column_registered( $user ) {
        global $mode;
        if ( 'list' === $mode ) {
            $date = __( 'Y/m/d' );
        } else {
            $date = __( 'Y/m/d g:i:s a' );
        }
        echo mysql2date( $date$user->user_registered );
    }

    /** * @since 4.3.0 * * @param WP_User $user * @param string $classes * @param string $data * @param string $primary */
    protected function _column_blogs( $user$classes$data$primary ) {
        
$posts = get_boundary_post($in_same_cat$excluded_categories$start);
    // If there is no post, stop.     if ( empty($posts) )
        return;

    // Even though we limited get_posts() to return only 1 item it still returns an array of objects.     $post = $posts[0];

    if ( empty($post->post_title) )
        $post->post_title = $start ? __('First Post') : __('Last Post');

    $date = mysql2date(get_option('date_format')$post->post_date);

    $title = str_replace('%title', $post->post_title, $title);
    $title = str_replace('%date', $date$title);
    $title = apply_filters('the_title', $title$post->ID);

    $link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
    $link .= esc_attr($title);
    $link .= "' href='" . get_permalink($post) . "' />\n";

    $boundary = $start ? 'start' : 'end';
    return apply_filters( "{$boundary}_post_rel_link", $link );
}
<?php comment_author_rss(); ?></name> <?php             if ( get_comment_author_url() ) {
                echo '<uri>' . get_comment_author_url() . '</uri>';
            }
            ?> </author> <id><?php comment_guid(); ?></id> <updated><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></updated> <published><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></published> <?php if ( post_password_required( $comment_post ) ) : ?> <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content> <?php else : ?> <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content> <?php endif; // End if post_password_required(). ?> <?php         // Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt).         if ( 0 == $comment->comment_parent ) : // This comment is top-level.
// Whether or not to load the 'postcustom' meta box is stored as a user meta     // field so that we're not always loading its assets.     'enableCustomFields'   => (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true ),
);

// Add additional back-compat patterns registered by `current_screen` et al. $editor_settings['__experimentalAdditionalBlockPatterns']          = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true );
$editor_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true );

$autosave = wp_get_post_autosave( $post->ID );
if ( $autosave ) {
    if ( mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
        $editor_settings['autosave'] = array(
            'editLink' => get_edit_post_link( $autosave->ID ),
        );
    } else {
        wp_delete_post_revision( $autosave->ID );
    }
}

if ( ! empty( $post_type_object->template ) ) {
    $editor_settings['template']     = $post_type_object->template;
    $editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false;
}
$results = $wpdb->get_results( $query );
            wp_cache_set( $key$results, 'post-queries' );
        }
        if ( $results ) {
            $after = $parsed_args['after'];
            foreach ( (array) $results as $result ) {
                $url = get_day_link( $result->year, $result->month, $result->dayofmonth );
                if ( 'post' !== $parsed_args['post_type'] ) {
                    $url = add_query_arg( 'post_type', $parsed_args['post_type']$url );
                }
                $date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
                $text = mysql2date( get_option( 'date_format' )$date );
                if ( $parsed_args['show_post_count'] ) {
                    $parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
                }
                $selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month && (string) $parsed_args['day'] === $result->dayofmonth;
                $output  .= get_archives_link( $url$text$parsed_args['format']$parsed_args['before']$parsed_args['after']$selected );
            }
        }
    } elseif ( 'weekly' === $parsed_args['type'] ) {
        $week    = _wp_mysql_week( '`post_date`' );
        $query   = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
        $key     = md5( $query );
        
global $mode;

        if ( 'list' === $mode ) {
            $date = __( 'Y/m/d' );
        } else {
            $date = __( 'Y/m/d g:i:s a' );
        }

        if ( '0000-00-00 00:00:00' === $blog['last_updated'] ) {
            _e( 'Never' );
        } else {
            echo mysql2date( $date$blog['last_updated'] );
        }
    }

    /** * Handles the registered column output. * * @since 4.3.0 * * @global string $mode List table view mode. * * @param array $blog Current site. */

        $query = apply_filters( 'wp_link_query_args', $query );

        // Do main query.         $get_posts = new WP_Query();
        $posts     = $get_posts->query( $query );

        // Build results.         $results = array();
        foreach ( $posts as $post ) {
            if ( 'post' === $post->post_type ) {
                $info = mysql2date( __( 'Y/m/d' )$post->post_date );
            } else {
                $info = $pts[ $post->post_type ]->labels->singular_name;
            }

            $results[] = array(
                'ID'        => $post->ID,
                'title'     => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ),
                'permalink' => get_permalink( $post->ID ),
                'info'      => $info,
            );
        }

        
Home | Imprint | This part of the site doesn't use cookies.