You are here

function date_example_date in Date 8

Same name and namespace in other branches
  1. 5.2 date/date_admin.inc \date_example_date()
  2. 6.2 date/date_admin.inc \date_example_date()
  3. 6 date/date_admin.inc \date_example_date()
  4. 7.3 date_api/date_api.module \date_example_date()
  5. 7 date_admin.inc \date_example_date()
  6. 7.2 date_api/date_api.module \date_example_date()

Creates an example date.

This ensures a clear difference between month and day, and 12 and 24 hours.

5 calls to date_example_date()
DateFieldWidgetBase::formatOptions in date_field/lib/Drupal/date_field/Plugin/field/widget/DateFieldWidgetBase.php
Return the format options used by this widget.
DateTextWidget::settingsForm in lib/Drupal/date/Plugin/field/widget/DateTextWidget.php
Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().
DateWidgetBase::formatOptions in lib/Drupal/date/Plugin/field/widget/DateWidgetBase.php
Return the format options used by this widget.
date_format_type_options in date_api/date_api.module
Creates an array of date format types for use as an options list.
date_views_argument_handler_simple::options_form in date_views/includes/date_views_argument_handler_simple.inc
Add a form element to select date_fields for this argument.

File

date_api/date_api.module, line 502
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

function date_example_date() {
  $now = new DrupalDateTime();
  if (date_format($now, 'M') == date_format($now, 'F')) {
    date_modify($now, '+1 month');
  }
  if (date_format($now, 'm') == date_format($now, 'd')) {
    date_modify($now, '+1 day');
  }
  if (date_format($now, 'H') == date_format($now, 'h')) {
    date_modify($now, '+12 hours');
  }
  return $now;
}