Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 5, Time field display formats

by Mike Orriss Email: Anonymous

Time field display formats
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 1.0  to 6.0 421 downloads
Copyright: No significant restrictions

Size: 595 bytes
Updated on Thu, 18 Oct 2001 23:37:29 GMT
Originally uploaded on Sun, 09 May 1999 00:00:00 GMT
SHA1 Hash: AC232C211462123FDCBFE8264FEF61D3742E0D51
MD5 Hash: 624FA00CDDBE7922EAB21936714D13F1

    Explore the files in this upload

Question: How do you get a DBEdit field to display a TimeField as hh:mm, (versus hh:mm:ss), in AM/PM time or military time?

Answer: You can set the editing format by changing the value held in the SysUtils LongTimeFormat global variable.

Suppose that you wish to display and edit a TDateTimeField as:

'dd-mm-yyyy hh.nn'

Then you change its DisplayFormat property to: dd-mm-yyyy hh.nn

Plus you will need code such as:

procedure TForm1.FormCreate(Sender: TObject);
with SysUtils do begin
DateSeparator := '-';
TimeSeparator := '.';
ShortDateFormat := 'dd-mm-yyyy';
LongTimeFormat := 'hh.nn';

Note that Delphi uses ShortDate and LongTime and the 'nn' above is not a typo!

Wrapping the SysUtils around the code is a bit pedantic, but it does protect you from the effects of re-declaration of these variables.

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03