DateTime
DateTime object for storing and processing dates and times. DateTime objects can be created in DEACOM by using the new keyword in front of DateTime. The DateTime Constructors are visible in the Scripting tree in DEACOM. However, you do not use the .Constructor() method. Instead, you will use the keyword new followed by DateTime. If you pass the new DateTime parameters then those will be inside parenthesis. See example below.
The new DateTime constructor can take parameters to build the date:
Nothing: Returns Today's date without time
String: A string that is a properly formatted date, time, or date and time string.
Integers: A separate integer for each datetime component: year, month, day[, hour, minute, second] -- time components are optional.
Applies To
None
Properties and Methods
Sub-Classes
Available
The DateTime object is available in:
- 15.03.016
- All newer builds
Type
Object
Syntax
DateTime;
Parameters
None
Example
//--The following example show how you can create a new DateTime object
//--In the scripting tree in DEACOM, these are the 'Constructor' options
//--This example makes use of the Utility.FormatTime(Date, Seconds) method instead of the .LongTimeString or .ShortTimeString properties
var ldDateTime = new DateTime;
var ldConvert = new DateTime('2021-10-22 12:24:45');
var ldBuild = new DateTime(2021, 10, 22, 16, 7, 36);
Event.Form.MessageBox('ldDateTime: ' + ldDateTime.ShortDateString + ' ' + Utility.FormatTime(ldDateTime, true) +
'\nldConvert: ' + ldConvert.ShortDateString + ' ' + Utility.FormatTime(ldConvert, true) +
'\nldBuild: ' + ldBuild.ShortDateString + ' ' + Utility.FormatTime(ldBuild, true));
/* Expected prompt response:
ldDateTime: 10/22/2021 12:00:00am
ldConvert: 10/22/2021 12:24:45pm
ldBuild: 10/22/2021 04:07:36pm
*/