Skip to content

Instantly share code, notes, and snippets.

View offordscott's full-sized avatar

Scott Offord offordscott

View GitHub Profile
@rafaehlers
rafaehlers / gv_calculate_days.php
Last active November 14, 2017 18:04
Calculate days between two date fields
<?php
add_shortcode( 'gv_days', 'gv_calculate_days' );
function gv_calculate_days( $atts ) {
global $gravityview_view;
extract($gravityview_view->field_data); // create a $entry variable with current entry data array
extract( shortcode_atts(
array(
'start_date_id' => '',
'end_date_id' => '',
@rafaehlers
rafaehlers / gv_age.php
Last active May 21, 2018 20:06
Calculate a person's age based on a date field
<?php
add_shortcode( 'gv_age', 'gv_calculate_age' );
/**
* Calculate age in years based on entry data
*
* Usage inside a Custom Content field (Replace "2" with the ID of the date field):
*
* <code>