current_datetime example

$posts = new WP_Query( $query_args );

    if ( $posts->have_posts() ) {

        echo '<div id="' . $args['id'] . '" class="activity-block">';

        echo '<h3>' . $args['title'] . '</h3>';

        echo '<ul>';

        $today    = current_time( 'Y-m-d' );
        $tomorrow = current_datetime()->modify( '+1 day' )->format( 'Y-m-d' );
        $year     = current_time( 'Y' );

        while ( $posts->have_posts() ) {
            $posts->the_post();

            $time = get_the_time( 'U' );

            if ( gmdate( 'Y-m-d', $time ) === $today ) {
                $relative = __( 'Today' );
            } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) {
                $relative = __( 'Tomorrow' );
            }
Home | Imprint | This part of the site doesn't use cookies.