Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function jeff_event_pre_submission_filter($post_data, $form, $entry ) {
- if( $form["id"] != 9 )
- return $post_data;
- $time_start = strtotime( $entry[2] . ' ' . $entry[3] );
- if( $entry[9] == 'Yes') {
- #is multi day
- $time_end = strtotime( $entry[10] . ' ' . $entry[4] );
- } else {
- #one day event
- $time_end = strtotime( $entry[2] . ' ' . $entry[4] );
- }
- #_DURATION
- $_POST['input_43'] = duration( $time_start, $time_end );
- return $post_data;
- }
- function duration( $start, $end ) {
- $seconds = $end - $start;
- $days = floor( $seconds / 60 / 60 / 24 );
- $hours = $seconds / 60 / 60 % 24;
- $mins = $seconds / 60 % 60;
- $secs = $seconds % 60;
- $duration = array();
- if( $days > 0 )
- $duration['days'] = $days;
- if( $hours > 0 )
- $duration['hours'] = $hours;
- if( $mins > 0 )
- $duration['minutes'] = $mins;
- if( count($duration) == 0 )
- $duration['minutes'] = 0;
- return $duration;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement