Date

Using form_alter to change the default value of a date

If you need to set a default value for an exposed views filter, you can do it like this:

this example code will set a ranged date to have a default value of -30 days for the start date, and today for the end date

<?php
function hook_form_views_exposed_form_alter(&$form, $form_state, $form_id) {

  switch (
$form_state['view']->name) {
  case
'my_view_name':
   
// the Date object works only with this date format:
   
$datemask = 'Y-m-d';
   
$form['field_date_value']['min']['#default_value'] = date($datemask, time()-30*86400);
   
$form['field_date_value']['max']['#default_value'] = date($datemask);
    break;

   
$datemask = 'd/m/Y';
   
$form['field_date_value']['min']['#date_format'] = $datemask;
   
$form['field_date_value']['max']['#date_format'] = $datemask;
  }
}
?>

Date iCal

Installation

Date iCal has several required dependencies, and an optional one:

  • The Views, Entity API, Libraries API (version 2.0), and Date modules are required.
  • The iCalcreator library is required.
  • PHP 5.3 is required by the iCalcreator library to properly handle timezone data. Date iCal *might* work with PHP 5.2, but that configuration is untested and unsupported.
  • The Feeds module is needed to enable import of iCal feeds from other sites, but if you don't plan to import external calendars, you don't need to install it.

To install the iCalcreator library, download it from here and extract the zip file. Inside that file you'll find iCalcreator.class.php. Copy that file to a folder in your Drupal site named "sites/all/libraries/iCalcreator".

Read more

Date API DateObject Class and Functions

The Drupal 7 Date module provides a helpful class -- DateObject -- and many helpful functions for the manipulation of date and time values in code and the storage of these values in your site's database. The class and functions are well-documented here on DrupalContrib.

Using the DateObject class delivers advantages to any coder who needs to handle dates and times (referred to for the rest of this article as 'times') with proper consideration for time zones or needs to perform time arithmetic, combine time values, format time values for display, and other tasks. The class extends the PHP DateTime class and so includes all of the native capabilities of PHP for time value handling.

Create a DateObject

Read more

Cookbook: set up Japanese era date on a multilingual site

This Cookbook shows how you can set up a date field to use a different Date format for each language. We will assume there are two languages present; English and Japanese, Japanese era module will be used to help format the date for the Japanese interface, and there is a content type with a Date field.

The example date we will be using is January 31st 2012. The date display we want to achieve is 2012/01/31 for English, and 平成24年1月31日 for Japanese interface. The Formating strings for these displays are Y/m/d and E年n月j日 respectively.

1. Create a new date Format for use in English
You can do that on the Date and time configuration page on the Formats tab:
Configuration > Regional and language > Date and time > Formats > Add format or visit
/admin/config/regional/date-time/formats/add, enter Y/m/d as the Format string
2. Create a new date Format for use in Japanese
Again you can do that on the Date and time configuration page on the Formats tab:
Configuration > Regional and language > Date and time > Formats > Add format or visit
Read more

Step by step guide to create an event listing with calendar block in Drupal 6

The contents of this guide is a Drupal 6 adaptation of the guide Step by step guide to create an event listing with calendar block in Drupal 7

Below are the list of steps to create an events listing with a calendar block which filters them.

Download and enable the required modules

  • latest development build of calendar, date, ctools and views modules (tested with Views 2, but it should easily work with version 3 as well)
  • context and context_ui.
  • features (needed by the feature module mentioned above).

(I didn't use Context and Features modules on my tests, if you want to use them you should follow and compare both guides.)

Create an Events content type

Read more
Subscribe with RSS Syndicate content
nobody click here