How to display an icon when a new post is published and then remove it when a specific time past?

Filter the content of post_class():

add_filter( 'post_class', function( $classes ) {

    if ( is_singular() )
        return $classes;

    // now minus last mod time in seconds
    $diff = time() - mysql2date( 'U', $post->post_date );

    if ( DAY_IN_SECONDS <= $diff )
        $classes[] = 'new-post';

    return $classes;
});

Now, in your loop, use post_class(), and you get an extra class you can use in your stylesheet:

.new-post {
    padding-left: 20px;
    background-image: url(new.png) left top no-repeat;
}

error code: 523