Utility.FormatTime(Date[, Seconds, 24Hour])
.FormatTime() returns the time portion of the provided DateTime object.
Applies To
Description
The Utility.FormatTime() function returns the time portion of the provided DateTime object in the standard DEACOM time format of HH:MMam/pm or HH:MM:SSam/pm if using the optional Seconds logical. You can see examples of this time format throughout DEACOM. One example is the Bill-To Customer's Credit Notes
Properties and Methods
None
Available
The .FormatTime(Date[, Seconds, 24Hour]) method is available in:
- 15.03.016
- All newer builds
Type
String
Syntax
Utility.FormatTime(Date[, Seconds, 24Hour]);
Parameters
|
Parameter |
Required |
Description |
|---|---|---|
|
Date |
Yes |
Any values outside the ranges above will result in a scripting error. |
|
Seconds |
No |
If set to true, will return the seconds portion of the time. |
|
24Hour |
No |
If set to true, will return the time with hours ranging from 0-23. |
Example
Event.Form.MessageBox('The current time using DateTime.Today is: ' + Utility.FormatTime(DateTime.Today) +
'\nThe current time using DateTime.Now is: ' + Utility.FormatTime(DateTime.Now) +
'\nThe current time using DateTime.Now with the optional Seconds logical is: ' + Utility.FormatTime(DateTime.Now, true) +
'\nThe time using a DEACOM time field integer (1811) is: ' + Utility.FormatTime(1811) +
'\nThe time using a string (\'18:21\') is: ' + Utility.FormatTime('18:21'));
/* Expected System Prompt Display:
The current time using DateTime.Today is: 12:00am
The current time using DateTime.Now is: 06:13pm
The current time using DateTime.Now with the optional Seconds logical is: 06:13:15pm
The time using a DEACOM time field integer (1811) is: 06:11pm
The time using a string ('18:21') is: 06:21pm
*/