How To Count Est Date To Current Date

Here is the example snippet that produce short code to display year count from establish date to current date automatically in Bricks builder. You can use with rich text element in Bricks by inserting above shortcode.

Copy and paste below code in child theme php file or you can use wpcodebox and other script organizers.

Shortcode :

[year_count]

PHP snippet :

/* Est Year Count */
function year_count_shortcode() {
    $from_year = 2003; // Change this to your starting year
    $current_year = date('Y');
    $years = array();
    for ( $year = $from_year; $year <= $current_year; $year++ ) {
        $years[] = $year;
    }
    return count($years) ;
}
add_shortcode('year_count', 'year_count_shortcode');

Leave comment or code correction