home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (date_php4.module)

This example Drupal source code file (date_php4.module) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, computations, date, date_php4, form, function, php, php4, return, settings, the, timezone, to, type

The date_php4.module Drupal example source code

// $Id: date_php4.module,v 2008/10/05 17:05:20 karens Exp $

 * @file
 * Include PHP 4 date handling files on systems where native date and
 * timezone handling won't work. This module will create the functions
 * date_create(), date_offset_get(), etc. that will work in PHP 4.
 * This module is not needed on systems using PHP 5.2+ and won't be needed once
 * Drupal requires PHP 5.2.

require_once('./'. drupal_get_path('module', 'date_php4') .'/date_php4.inc');

 * Implementation of hook_perm().
function date_php4_perm() {
  return array('administer date_php4 settings');

 *  Implementation of hook_menu().
function date_php4_menu() {
  $items = array();
  $items['admin/settings/date_php4'] = array(
    'title'    => 'Date PHP4',
    'description' => 'Date PHP4 setup.',
    'access arguments'   => array('administer date_php4 settings'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('date_php4_settings_form'),
    'type' => MENU_NORMAL_ITEM,
    'weight' => 6,
  return $items;

 *  Timezone handling.
function date_php4_settings_form() {
  drupal_set_title(t('Date PHP4 Settings'));
  $form['date_use_server_zone'] = array(
    '#type' => 'select',
    '#options' => array(TRUE, t('TRUE'), FALSE => t('FALSE')),
    '#default_value' => variable_get('date_use_server_zone', FALSE),
    '#title' => t('Use PHP default timezone'),
    '#description' => t('Getting date computations working correctly in PHP versions earlier than PHP 5.2 involves extra computations that add a lot of overhead. These computations are needed because the timezone PHP uses on date computations may not match the site or user timezone or other date-specific timezones. We can speed processing up if we assume that PHP is using the correct timezone, but need to do more time-intensive processing if it is not. If timezone adjustments do not seem to be working correctly in your setup, you can set this option to FALSE to force the system to use the more accurate, but slower, timezone computations.'),
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  return $form;

function date_php4_settings_form_submit($form, &$form_state) {
  variable_set('date_use_server_zone', $form_state['values']['date_use_server_zone']);

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal date_php4.module source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.