DateTime.Now.ShortTimeString

.ShortTimeString converts the time portion of the DateTime object and returns the time to the minute. The results will be formatted as: hh:mm. There is no am/pm value with this and the hour value will be between 0 and 23. To get the time to show am/pm you will need to use the Utility.FormatTime(Date[, Seconds]) method.

Note: The .Today method does not have a time component and will always return a 0.

Applies To

Properties and Methods

None

Available

The .ShortTimeString property is available in:

  • 15.03.016
  • All newer builds

Type

String

Syntax

DateTime.Now.ShortTimeString;

Parameters

None

Example

var ldToday = DateTime.Today;

var ldNow = DateTime.Now;

var ldNew = new DateTime('06/10/2021 12:34:56');

Event.Form.MessageBox('Get the .ShortTimeString:' +

'\nldToday: ' + ldToday.ShortTimeString +

'\nldNow: ' + ldNow.ShortTimeString +

'\nldNew: ' + ldNew.ShortTimeString);

 

/* Expected Prompt response:

Get the .ShortTimeString:

ldToday: 00:00

ldNow: 13:11

ldNew: 12:34

*/