Skip to main content
Articles

Plugin for Calculating Anniversaries or Mile Stone Dates with Code!

Here's a simple WordPress function and short code for calculating things like employee anniversaries, years in business, birthdays or anything that needs to calculate a year based on a starting date.Example 1: Celebrating [workiversary anniversary="12-12-2002"] Years! Celebrating [workiversary anniversary="12-12-2002"] Years! Exanple 2: Celebrating Over [workiversary anniversary="12-12-1832"] Years in Business! Celebrating Over [workiversary anniversary="12-12-1822"] Years in Business! Add this to your themes Functions, or create your own plugin: function status_in_years_shortcodes( $atts ) {if ( empty( $atts['anniversary'] ) ) return '';if ( ( $anniversary = strtotime( $atts['anniversary'] ) ) === false ) return '';$years_diff = date_diff( date_create(), date_create( $atts['anniversary'] ) )->y; return $years_diff;} add_shortcode( 'workiversary', 'status_in_years_shortcodes' );