You are here: Core Reference > Coding > Scripting > DateTime.Format

DateTime.Format

The DateTime Control Object that is returned by the AddDateTime function has a Format property. The Format property can be used to define how Date and Time values are displayed.

Syntax

ControlObject.Format = DateTime Format

Where ControlObject. is the name of the variable (declared in your script) that is used to store the DateTime Control Object that is returned by the AddDateTime function.

Description

Use to define how Date and Time values are displayed.

Arguments

DateTime Format {string}

This string sets the date and time format and consists of a combination of the following characters:

  • d—day of month with no leading zero, for example, 4
  • dd—day of month with leading zero, for example, 04
  • EEE—abbreviated day of week, for example, MON
  • EEEE—day of week in full, for example, MONDAY
  • M—month with no leading zero, for example, 9 (for September)
  • MM—month with leading zero, for example, 09 (for September)
  • MMM—abbreviated month, for example, Apr
  • MMMM—month in full, for example, April
  • yy—2 digit year, for example, 06 (for 2006)
  • yyyy—year in full, for example, 2006
  • h—hour in 12 hour clock format without a leading zero
  • hh—hour in 12 hour clock format with a leading zero (where applicable)
  • H—hour in 24 hour clock format without a leading zero
  • HH—hour in 24 hour clock format with a leading zero (where applicable)
  • m—minutes with no leading zero
  • mm—minutes with leading zero (where applicable)
  • s—seconds with no leading zero
  • ss—seconds with leading zero (where applicable)
  • S—milliseconds
  • A—indicates whether the time is AM or PM.

Example:

DateTime1.Format = "d/MM/yyyy"

Where:

  • DateTime1 is the name of the variable used to store the DateTime Control Object that is returned by the AddDateTime function (which would be defined earlier in the script)
  • "d/MM/yyyy" sets the date to be displayed as day of month with no leading zero, then month with leading zero, then a four digit year, for example, "5/06/2006" sets the date to 5th June 2006.

ClearSCADA 2015 R2