GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
time.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Display the time field type
4  *
5  * @package GravityView
6  * @subpackage GravityView/templates/fields
7  */
8 
10 
11 $gv_field = $gravityview_view->getCurrentField();
12 
13 /** @type string $value Raw time value */
14 $value = \GV\Utils::_GET( 'value', \GV\Utils::get( $gv_field, 'value' ) );
15 
16 // strtotime() fails at "00:00 am"; it returns false instead of midnight.
17 if ( false !== strpos( $value, '00:00' ) ) {
18  $value = '00:00';
19 }
20 
21 /** @type string $field_id ID of the field being displayed */
22 $field_id = \GV\Utils::_GET( 'field_id', \GV\Utils::get( $gv_field, 'field_id' ) );
23 
24 $output = '';
25 
26 if( '' !== $value ) {
27 
28  /** @type GF_Field_Time $field Gravity Forms Time field */
29  $field = \GV\Utils::_GET( 'field', \GV\Utils::get( $gv_field, 'field' ) );
30 
31  $format = $gravityview_view->getCurrentFieldSetting( 'date_display' );
32 
33  if ( empty( $format ) ) {
34 
35  $field->sanitize_settings();
36 
38  }
39 
40  // If there is a custom PHP date format passed via the date_display setting, use PHP's date format
41  $output = date_i18n( $format, strtotime( $value ) );
42 }
43 
44 echo $output;
$value
string $value Raw time value
Definition: time.php:14
static _GET( $name, $default=null)
Grab a value from the _GET superglobal or default.
static getInstance( $passed_post=NULL)
if(gv_empty( $field['value'], false, false)) $format
$output
Definition: time.php:24
$gv_field
Definition: time.php:11
$gravityview_view
Definition: time.php:9
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
Definition: time.php:22
static date_format( $time_format='12', $field_id=0)
Get the default date format for a field based on the field ID and the time format setting...