Years Diff
Years Diff
// Add Shortcode
function years_diff_shortcode( $atts ) {
// Attributes
extract( shortcode_atts(
array(
'start' => 'now',
'end' => 'now',
), $atts )
);
// Code
$init = new DateTime($start);
$finit = new DateTime($end);
$interval = $init -> diff($finit);
return $interval -> format('%Y');
}
add_shortcode( 'years_diff', 'years_diff_shortcode' );