You are here

date-types.html in Date 7

Same filename and directory in other branches
  1. 6.2 help/date-types.html

File

help/date-types.html
View source
<h3>Date Fields</h3>
<p>The CCK Date field uses the <a href="topic:date_api/overview">Date API</a> to create date fields and widgets.</p>
<p>You have a choice of creating an ISO date or a unix timestamp. If you are porting information from another application you may want to create a field using a type that matches the source data. Some advantages and disadvantages of each include:</p>
<dl>
<dt>Datestamp (Unix Timestamp)</dt>
<dd><ul>
<li>Stores the date as an integer.</li>
<li>Takes up less room in the database because it's smaller.</li>
<li>Often easier to use for date calculations because you can increase or decrease it just by adding or subtracting seconds.</li>
<li>It is the format used by php date functions.</li>
<li>It must be filled with a complete date -- year, month, day, hour, minute, second, so you sometimes have to arbitrarily set some of these values even if they are not applicable.</li>
</ul></dd>

<dt>Date (ISO Date)</dt>
<dd><ul>
<li>Stores the date in an ISO format (YYYY-MM-DDTHH:MM:SS).</li>
<li>The data is in a human-readable form.</li>
<li>You can use it for incomplete dates, i.e. only a year or only a year and a month, and pad the other values with zeros, so it does not appear to be any more precise than it really is.</li>
<li>It is a format that is internationally-recognized, and it is used as-is on many web sites and in many applications.</li>
</ul></dd>

<dt>Datetime</dt>
<dd><ul>
<li>Stores the date in the database's native date format (YYYY-MM-DD HH:MM:SS).</li>
<li>The data is in a human-readable form.</li>
<li>You can use it for incomplete dates, i.e. only a year or only a year and a month, and pad the other values with zeros, so it does not appear to be any more precise than it really is.</li>
<li>It can take advantage of the database's date handling functions without any conversion.</li>
</ul></dd>
</dl>
<h3>Date Widgets</h3>
<p>There are several widgets to choose from to control how users can enter data for this field.</p>
<dl>
<dt>Text Field</dt><dd>The Text Field date widget uses a custom format set in the field settings, like '31.12.2008'. As a fallback the widget will try to accept input allowed by the php <a href="http://www.php.net/manual/en/function.strtotime.php">strtotime function</a>. This allows the user to type a date in in many natural formats, like 'March 31, 1980'. 
There are limitations to strtotime, so setting a custom format is more reliable. The strtotime function will assume date shortcuts are in American format (MM/DD/YY), and strtotime will not work for dates prior to 1970. 
</dd>
<dt>Select List</dt><dd>The Select List date widget presents users with a drop-down list or textfield for each part of the date (year, month, day, hour, etc.). The whole selector is collapsed onto a single line using css (except for the timezone selector, if date-specific timezones are collected). The selector is highly configurable and you can set it up to use 5, 10, or 15 minute increments for minutes and seconds, or make some parts of the selector use textfields instead of drop-downs, useful to allow any year without creating a huge drop-down selector.</dd>
<dt>jQuery Pop-up Calendar</dt><dd>The Javascript Pop-up Calendar is offered as an input alternative if the Date Popup module is installed. The date is split into date and time fields, and the date field uses a jQuery popup calendar and the time field uses a jQuery timeselector widget that only allows valid time input.
</dl>
<p>If you have the Date Repeat module enabled, you will also see options for each of those widgets that include a repeat options selection form that will allow the user to choose values like 'Every week' or 'The last Tuesday'.</p>