GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-date.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default date field output template.
4  *
5  * @global \GV\Template_Context $gravityview
6  * @since 2.0
7  */
8 
9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
11  return;
12 }
13 
14 $field_id = $gravityview->field->ID;
15 $field = $gravityview->field->field;
16 $value = $gravityview->value;
17 $field_settings = $gravityview->field->as_configuration();
18 
19 /**
20  * Unix Epoch probably isn't what you're looking for.
21  * @since 1.7
22  */
23 if ( $value === '1970-01-01' ) {
24 
25  /**
26  * @filter `gravityview/fields/date/hide_epoch` Whether to hide `1970-01-01` dates; that is normally an erroneous date. Return false to show value. Use `__return_false` callback.
27  * @param bool $hide_epoch True: hide values that are 1970-01-01. False: show the value.
28  *
29  * @since 2.0
30  * @param \GV\Template_Context $gravityview The $gravityview context object.
31  */
32  $hide_epoch = apply_filters( 'gravityview/fields/date/hide_epoch', true, $gravityview );
33 
34  if ( $hide_epoch ) {
35  return;
36  }
37 }
38 
39 if ( ! empty( $field_settings ) && ! empty( $field_settings['date_display'] ) && ! empty( $value ) ) {
40 
41  // If there is a custom PHP date format passed via the date_display setting,
42  // use PHP's date format
43  $format = $field_settings['date_display'];
44  $output = date_i18n( $format, strtotime( $value ) );
45 
46 } else {
47 
48  $output = GravityView_Field_Date::date_display( $value, \GV\Utils::get( $field, "dateFormat" ), $field_id );
49 
50 }
51 
52 echo $output;
$value
Definition: field-date.php:16
if(gv_empty( $field['value'], false, false)) $format
$field
Definition: field-date.php:15
gravityview()
The main GravityView wrapper function.
if(! isset( $gravityview)||empty( $gravityview->template)) $field_id
The default date field output template.
Definition: field-date.php:14
static date_display( $value='', $date_format='mdy', $field_id=0)
Get the default date format for a field based on the field ID and the time format setting...
$field_settings
Definition: field-date.php:17