A WMS server can provide support to temporal requests. This is done by providing
a TIME parameter with a time value in the request. MapServer 4.4 and above
provides support to interpret the TIME parameter and transform the resulting values
into appropriate requests.

WMS specifies that the basic format used for TIME requests is based on the ISO
8601:1988(E) “extended” format. MapServer supports a limited set of patterns that
are defined in the ISO 8601 specifications, as well as few other patterns that are
useful but not compliant to ISO 8601. Here is a list of patterns currently supported:

To have a valid WMS layer with time support, the user has to define the following
metadata at the layer level:

wms_timeextent: (Mandatory) this is used in the capabilities document to
return the valid time values for the layer. The value defined here should be a
valid time range. (more on this in ‘Specifying Time Extents’ below)

wms_timeitem: (Mandatory) this is the name of the field in the DB that
contains the time values.

wms_timedefault: (Optional) this value is used if it is defined and the
TIME value is missing in the request.

It is also recommended to set a LAYERFILTER for the time
layer to provide a default time also for non-WMS requests. If the
time item is mytime, and the time format is “YYYYMMDD” the following
layer filter could be used:

When MapServer receives a request with a TIME parameter, it transforms the time
requests into valid expressions that are assigned to the filter parameter on
layers that are time-aware. Here are some examples of how different types of
requests are treated (wms_timeitem is defined here as being “time_field”):

As shown in the above examples, all fields and values are written inside back
tics (`) - this is the general way of specifying time expressions inside MapServer.

Exceptions to this rule:

When dealing with layers that are not Shapefiles nor through OGR, the
expression built has slightly different syntax. For example, the expression
set in the filter for the first example above would be ([time_field] = ‘2004-10-12’).

For PostGIS/PostgreSQL layers, the time expression built uses the date_trunc function
available in PostgreSQL. For example, if the user passes a time value of ‘2004-10-12’,
the expression set in the filter is date_trunc(‘day’, time_field) = ‘2004-10-12’.
The use of the date_trunc function allows requests to use the concept of time
resolution. In the example above, for a request of ‘2004-10-12’, MapServer determines
that the resolution is “day” by parsing the time string and the result gives all
records matching the date 2004-10-12 regardless of the values set for
Hours/Minutes/Seconds in the database. For more information on the date_trunc function,
please refer to the PostgreSQL documentation.

The user has the ability to define the time format(s) to be used when a request is sent,
in metadata at the WEB level. For example, the user can define the following two formats:

"wms_timeformat""YYYY-MM-DDTHH, YYYY-MM-DDTHH:MM"

Another example is for a WMS layer that is based on time data that contains precise time
values taken every minute (e.g., 2004-10-12T13:55, 2004-10-12T13:56, 2004-10-12 T13:57, ...).
Normally, a valid request on such a layer would require the time value to be as
complete as the data underneath. By defining a set of patterns to use, MapServer
introduces the notion of resolution to be used when doing a query. Using the example
above, a request TIME= 2004-10-12T13:55 would be valid and a request TIME= 2004-10-12T13
would also be valid and would return all elements taken for that hour.

Note that this functionality is only available on layers based on Shapefiles and OGR.