Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.