Help:Type Date

Jump to: navigation, search
Holds particular points in time
Further Information
Provided by: Semantic MediaWiki
Added in version: 1.4.0
Removed in version: still in use
Table of Contents

The datatype Date is used for data values that represent points in time. It is able to support dates throughout human history in a unified format, and it offers internationalisation options for supporting more languages. All dates and times refer to the "local time" of the server (or the wiki). A wiki may define what timezone this refers to by common conventions. For export, times are given without timezone information. However, time offsets to that local time are supported.

Since SMW 1.8.0 dates are stored in a full serialised format, including the calendar model.

Display format


Dates are displayed in a simple format that cannot be changed with the language setting in the user preferences. Month names in displayed dates are just translated based on the wiki's current language (if translated names are available). User settings are not taken into account for displaying dates. Starting with version 1.7.0 of Semantic MediaWiki you can also use "MEDIAWIKI" behind the printout request to use the MediaWiki's i18n methods for time and date formatting. It has superior i18n support, but cannot handle all possible values such as BC dates.

To correspond with the MediaWiki output, "MEDIAWIKI" will recognize the user settings in terms of preference and language settings.


See 1


In case you want to keep the simple format in printout request of queries (Inline queries or Concepts) you may use "ISO" behind the printout requests of this type. Thus instead of displaying "Jan 9 2008" (achieved with printout request ?birthday) you will get "2008-01-09" (achieved with printout request ?birthday#ISO) which is a plain format representing an ISO formatted international date string.

Display takes into account if parts of a date were omitted. So a date specified as "2008" will also be printed as "2008" everywhere, even though it might be interpreted as "Jan 1 2008 00:00:00" when comparing it to other dates.

F (free formatted)

Starting with SMW 2.4 2, the free format is supported where a options string in form of D M j G:i:s T Y (see DateTime) can be used to generate an individual printout.

  • Dates like 10000 BC (prehistroy) are not supported by the formatter (the ISO date --10000-01-01 is returned instead) other BC(E) dates like 2 Feb 900 BC will be formatted as -0900/01/25 or -0900/02/02 JL
  • Dates stored with a JD(JL) are not automatically transformed and instead marked with JL to indicate its model
{{#ask: [[Example]]
 |?Date#GR-F[Y/m/d H:i:s]=Label 1 (GR)
 |?Date#-F[Y/m/d H:i:s]=Label 2
 |?Date#-F[D M j G:i:s T Y]=Label 3
 |?Date#-F[l jS \of F Y h:i:s A]=Label 4


Return a number that helps comparing time data items. For dates in the Julian Day era (roughly from 4713 BCE onwards) its is equivalent to the the Julian Day number. For earlier dates, the (negative) year number with a fraction for the date is used (times are ignored).


Returns the Julian day of a date value.

Input examples

Examples of typical input dates in English language are
annotation result remark
[[Has date::Feb 11 2000 10:00:01]] Feb 11 2000 10:00:01 complete date with time
[[Has date::Feb 11 2000]] Feb 11 2000 just date
[[Has date::Feb 2000]] Feb 2000 month and year
[[Has date::2000]] 2000 year by itself
[[Has date::Feb 11 2000 10:00:01 PM]] Feb 11 2000 10:00:01 PM complete date with time, PM
[[Has date::Feb 11 2000 22:00:01]] Feb 11 2000 22:00:01 complete date with 24h time
[[Has date::2000-02-11T22:00:01]] 2000-02-11T22:00:01 ISO-style date
[[Has date::2000-02-11T22:00:01+02:00]] 2000-02-11T22:00:01+02:00 ISO-style date with offset
[[Has date::2000 February 2]] 2000 February 2 varying order of inputs is supported
[[Has date::2-3-2000]] 2-3-2000 preferred interpretation, month or day, sometimes depends on language settings
[[Has date::2/3/2000]] 2/3/2000 various kinds of separators are recognized in all languages
[[Has date::Jan 1 300 BC]] Jan 1 300 BC dates BC/before common era are supported
[[Has date::14000000000 BC]] 14000000000 BC estimated age of the universe
[[Has date::Feb 11 2000 Jl]] Feb 11 2000 Jl date of the Julian Calendar
[[Has date::Feb 11 1492 Gr]] Feb 11 1492 Gr date is treated as Gregorian
[[Has date::Feb 11 2000 10:00 GMT]] Feb 11 2000 10:00 GMT date with time zone shortcut
[[Has date::2000-02-22]] 2000-02-22 MySQL date format
The annotation in the following examples is incorrect
wrong annotation result remark
[[Has date::1999-00-00]] 1999-00-00
The date "1999-00-00" was not understood.
MySQL partial date format
[[Has date::Sun Jun 20 23:21:05 1993]] Sun Jun 20 23:21:05 1993
The date "Sun Jun 20 23:21:05 1993" was not understood.
unrecognized order

Other languages may also support additional strings as month names, and they may choose different preferred interpretations of ambiguous dates. The basic format, however, is the same.

Further examples

Calendar models

At the moment, Type:Date supports two calendar models: Gregorian and Julian In 1582 the Catholic Church introduced a reform of the calendar Julian calendar. So dates before 24. February 1582 are supposed to refer to Julian calendar by default. The dates after the reform are considered Gregorian accordingly. However, one can manually specify the calendar model of the entered date by annotating it with Jl or Gr (Old Style (OS) is also understood). Internally, Type:Date uses the proleptic Gregorian calendar, an extension of the Greogorian calendar to the past, to represent dates.

SMW 1.8.0 added support for new output formats "GR" and "JL" that can be used in inline queries to define the desired calendar model that should be displayed. The same strings also work as modifiers when writing dates. If nothing is given, SMW will assume the same default calendar model on input and on output.

Instead of displaying the annotated date „6 November 1796 Jl“ with the output statement ?Geburtsdatum, one may have this date displayed as „17 November 1796 Gr“ by using the output statement ?Geburtsdatum#GR.

SMW 2.4 is to indicate the CalendarModel for a date if is not a Greogorian calendar date and SMW_DV_TIMEV_CM1 can be used to disable this option .

Maximal date range

Type:Date is able to handle dates across history with full precision for storing, and substantial precision for sorting and querying. The range of supported past dates should encompass the Beginning of Time according to most of today's theories. The range of supported future dates is limited more strictly, but it does also allow year numbers in the order of 10^9.

Era information

Display of era information for positive years 4 (if denoted) is supported starting with SMW 2.4.

BC, negative years, and the year 0

Years before common era (aka BC) can be denoted using "BC" in a date. It is assumed that there is no "year 0": the historic sequence of years was ..., 2 BC, 1 BC, 1 AD, 2AD, ... When given as an input, the year 0 (BC or not) is interpreted as 1 BC, but this use is discouraged.

The internal numeric date model used in SMW supports the year 0, and considers it to be the same as "1 BC". According to this convention, e.g., the year "-100" is the same as "101 BC". This convention agrees with ISO 6801 and the remarks in XML Schema Datatypes 2nd Edition (the latter uses a different convention that disallows year 0, but it explicitly endorses the ISO convention and announces the future use of this in XML). Note that the implementation currently does not support the specification of negative year numbers as input; negative numbers are only used internally.

Time offsets and timezones

Time offests are supported (e.g. "1 1 2008 12:00-2:00"). As explained above, those refer to the local time. Time offsets take leap years into account, e.g. the date "Feb 28 2004 23:00+2:00" is equivalent to "29 February 2004 01:00:00", while "Feb 28 1900 23:00+2:00" is equivalent to "1 March 1900 01:00:00". Additionally, offsets can be specified by the common shortcuts for time zones (e.g. ADT, AST, CET, CST, CXT, EST, HAC, HAT, HNR, MEZ, MST, NFT): "1 March 1998 08:00:00 EST".

Sorting dates in tabular outputs

The sortable table code of MediaWiki cannot handle dates. To make them sort properly, one needs to provide numeric sortkeys using the "data-sort-value" attribute in td elements (look at the HTML of any real SMW table for examples). To allow this to be done, the new parameter "#SORTKEY" was added to this datatype by which one can obtain a numeric sortkey as needed for "data-sort-value". For example, the following query displays dates and their sortkeys:

{{#ask: [[Modification date::+]]
| ?Modification date
| ?Modification date#SORTKEY

For properties that can have many values, only one sortkey must be used (since the whole table row is sorted as one, even if many dates are in one cell). This can be achieved by using parameter "+limit" like in this example:

{{#ask: [[testdate::+]]
| ?testdate
| ?testdate#SORTKEY |+limit=1

Handling of incomplete dates

The implementation notices and stores whether parts of a date/time have been omitted (as in "2008" or "May 2007"). For all exporting and sorting purposes, incomplete dates are completed with defaults (usually using the earliest possible time, i.e. interpreting "2008" as "Jan 1 2008 00:00:00"). But the information on what was unspecified is kept internally for improving behaviour e.g. for outputs (defaults are not printed when querying for a value).

Only the minor parts of a date can be omitted: "May 2008" works, but "May 1" does not. This is so, since the latter could not be given a sensible default interpretation when sorting dates. To support sorting and querying, all dates must be interpretable as a concrete precise time point, and this is done internally when required, even for incomplete dates.

Technical notes

See 1

  • TimeValueFormatter::getCaptionFromDataItem uses the content language which is either the default content language or if available the page content language
  • ExtraneousLanguage::getPreferredDateFormatByPrecision determines a PHP DateTime format string as preference for a specific language in combination with a precision
  • IntlTimeFormatter::getLocalizedFormat (#LOCL) uses ExtraneousLanguage::getPreferredDateFormatByPrecision to determine the preferred localized representation for a date/time output

Open Issues

  • The customised date formatting of MediaWiki can only be used for dates between typically between 1901-12-14 and 2038-01-19.
  • Internationalisation is incomplete: "BC", "AD", "PM", "AM" are fixed for all languages.
  • Conversion between (historic) calendar models is not supported yet.

This documentation page applies to all SMW versions from 1.8.0 to the most current version.
Other versions: 1.7.1 – – – 1.6.2       Other languages: de

Help:Type Date en 1.8.0


  1. a b c  #LOCL as TimeValue output format
  2. ^  free date/time formatting support
  3. ^  #1397
  4. ^  #1396 Indicate AC/CE era for positive years if it was explicitly annotated]