Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 17, 2012 20:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/1628700 to your computer and use it in GitHub Desktop.
Save billerickson/1628700 to your computer and use it in GitHub Desktop.
Gravity Forms - UNIX Timestamp
<?php
add_action( 'gform_post_submission_1', 'be_event_timestamp', 10, 2 );
/**
* Create a UNIX timestamp based on Gform date fields
* @author Bill Erickson
* @link http://www.billerickson.net/code/gravity-forms-unix-timestamp
* @link http://www.gravityhelp.com/documentation/page/Gform_post_submission
*
* 'gform_post_submission' applies to all forms, append form ID to specify
*
* @param array $entry
* @param array $form
* @return array
*/
function be_event_timestamp( $entry, $form ) {
$start_date = get_post_meta( $entry['post_id'], 'be_event_start_date', true );
if( $start_date ) {
$timestamp = strtotime( $start_date );
update_post_meta( $entry['post_id'], 'be_event_start_date_unix', $timestamp );
}
$end_date = get_post_meta( $entry['post_id'], 'be_event_end_date', true );
if( $end_date ) {
$timestamp = strtotime( $end_date );
update_post_meta( $entry['post_id'], 'be_event_end_date_unix', $timestamp );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment