Date / Time

The Date/Time validation checks the contents of a specified server variable to determine if its value complies with the specified date and/or time format, and also falls within an acceptable range of values. It can also be configured to accept blank entries.



Set the configuration options and click OK to complete configuration of the validation within the Server Validation dialog.

The following options are available for configuration of the Alphanumeric validation:
  • Select whether you want to validate against date, time, or both by checking the appropriate field at the top of each section.

    Note: If validating against both a date and a time, values entered into the selected form element must be entered with the date first, followed by the time. As well, a space must separate the two values in order for the validation to pass.
  • The configuration of date and time validation criteria both require the same configuration information.

    To configure validation criteria, for date and/or time:

    • Select the format which is accepted by the validation from the list of available choices, or choose to accept any format.
    • Specify the minimum and maximum date and/or time that the validation accepts. Leave these fields blank if the validation is not checking for a set range of dates and/or hours.

      Depending on what you've chosen for your allowed date format, dates are expected one of two ways:

      For european date formats day[-/.]month[-/.]year, enter dates dd/mm/yyyy.

      For all other dates, enter in the form mm/dd/yyyy.

      Time values should be entered using a 24 hour standard (e.g. 14:56:56)
    • Select the format the data that passes the validation is to be reformatted to, or choose to keep the existing format.
  • Select whether the validation allows blank entries or not.

Using referential dates and times

It is possible to configure this validation to accept a time on a specific date as the maximum or minimum value. For this configuration to work correctly, check both the date and the time options, enter the minimum and maximum date and time in the corresponding date fields, but leave the minimum and maximum time fields blank. When entering the compared values, be sure the date is first followed by the time, using a space to separate the two.

As well, it is possible to specify referential dates, meaning that the date is not a specified day, month and year, but relative to the current date on the client browser.

Functions are available within each supported server language to specify within the Min and Max date/time fields to specify a relative date and time. These are:

ASP - Javascript

Function Description
Now right now
Now.setHours(Now.getHours()+24) 24 hours in the future
Now.setHours(Now.getHours()-24) 24 hours in the past
Today this morning
Today.setDate(Today.getDate()+1) 1 day in the future
Today.setDate(Today.getDate()-1) 1 day in the past
Today.setMonth(Today.getMonth()+1) 1 month in the future
Today.setMonth(Today.getMonth()-1) 1 month in the past
Today.setFullYear(Today.getFullYear()+1) 1 year in the future
Today.setFullYear(Today.getFullYear()-1) 1 year in the past

ASP - VBscript

Function Description
Now() right now
Date() this morning
DateAdd("h", 24, Now()) 24 hours in the future
DateAdd("h", -24, Now()) 24 hours in the past
DateAdd("d", 1, Date()) 1 day in the future
DateAdd("d", -1, Date()) 1 day in the past
DateAdd("m", 1, Date()) 1 month in the future
DateAdd("m", -1, Date()) 1 month in the past
DateAdd("yyyy", 1, Date()) 1 year in the future
DateAdd("yyyy", -1, Date()) 1 year in the past

Coldfusion

Function Description
Now() right now
LSParseDateTime(DateFormat(now(), "MM/DD/YYYY")) this morning
DateAdd("h", 24, Now()) 24 hours in the future
DateAdd("h", -24, Now()) 24 hours in the past
DateAdd("d", 1, LSParseDateTime(DateFormat(now(), "MM/DD/YYYY")) ) 1 day in the future
DateAdd("d", -1, LSParseDateTime(DateFormat(now(), "MM/DD/YYYY")) ) 1 day in the past
DateAdd("m", 1, LSParseDateTime(DateFormat(now(), "MM/DD/YYYY")) ) 1 month in the future
DateAdd("m", -1, LSParseDateTime(DateFormat(now(), "MM/DD/YYYY")) ) 1 month in the past
DateAdd("yyyy", 1, LSParseDateTime(DateFormat(now(), "MM/DD/YYYY")) ) 1 year in the future
DateAdd("yyyy", -1, LSParseDateTime(DateFormat(now(), "MM/DD/YYYY")) ) 1 year in the past

PHP

Function Description
Time(); right now
mktime(0, 0, 0, date("m"), date("d"), date("Y")); this morning
mktime(0, 0, time("H")+24, date("m"), date("d"), date("Y")); 24 hours in the future
mktime(0, 0, time("H")-24, date("m"), date("d"), date("Y")); 24 hours in the past
mktime(0, 0, 0, date("m") , date("d")+1, date("Y")); 1 day in the future
mktime(0, 0, 0, date("m") , date("d")-1, date("Y")); 1 day in the past
mktime(0, 0, 0, date("m")+1 , date("d"), date("Y")); 1 month in the future
mktime(0, 0, 0, date("m")-1 , date("d"), date("Y")); 1 month in the past
mktime(0, 0, 0, date("m") , date("d")+1, date("Y")+1); 1 year in the future
mktime(0, 0, 0, date("m") , date("d")+1, date("Y")-1); 1 year in the past