You are here

function timefield_integer_to_time in Timefield 1.0.x

Same name and namespace in other branches
  1. 7 timefield.module \timefield_integer_to_time()

Helper function to return time value from a timefield integer.

Parameters

array $settings: Field formatter settings. This is a structured array used to format a date with PHP's date() function. This array has the following keys: -separator The character(s) the go(es) between the hour and minute value -period_separator The character(s) the go(es) between the time string and the period (AM/PM) -period The PHP formatting option for period, or "none" to omit display -hour The PHP formatting option for hour -minute The PHP formatting option for minute @see _timefield_time_part_format() for some possible options. It is worth noting that no assumptions are made about how one wishes to format date output, e.g., 24-hour formatted times are not assumed to not have AM/PM period information.

integer $value: Integer offset from midnight to be converted to human-readable time. This value is basically number of seconds from midnight. If you wish to to show a time +1 day, your value can be greater than 86400.

Return value

string Human-readable time string

7 calls to timefield_integer_to_time()
template_preprocess_timefield in ./timefield.module
TimeFieldDefaultFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/TimeFieldDefaultFormatter.php
Returns a short summary for the current formatter settings.
TimeFieldDefaultFormatter::viewElements in src/Plugin/Field/FieldFormatter/TimeFieldDefaultFormatter.php
Builds a renderable array for a field value.
TimeFieldDuration::viewElements in src/Plugin/Field/FieldFormatter/TimeFieldDuration.php
Builds a renderable array for a field value.
TimeFieldStandardWidget::formElement in src/Plugin/Field/FieldWidget/TimeFieldStandardWidget.php
Returns the form for a single field widget.

... See full list

File

./timefield.module, line 68
Contains timefield.module.

Code

function timefield_integer_to_time($settings, $value) {
  $format = timefield_build_time_format($settings);
  if (isset($value)) {
    if ($value >= 86400) {
      $value = $value - 86400;
    }
    return date($format, mktime(0, 0, $value));
  }
  else {
    return '';
  }
}