Link to home
Start Free TrialLog in
Avatar of Motaz
Motaz

asked on

24 Hour format for Date time picker

I use DateTimePicker component, Time mode. I want to set it's time format to 24 hour time format. How can I do this ?
Avatar of Motaz
Motaz

ASKER

also I want to change time format of TeeChart (in QuickReport) to 24 hour format.
Make sure that your Windows settings are setup to use the 24 hour clock rather than the 12 hour one

The Neil
You can use the ShortDateFormat system variable to achieve this.  In the project source, store the initial setting for the variable in one of your own, set the 24hr type, and then restore at the end of the program.  Like this...

program Project1;

uses
  Forms, SysUtils,
  Unit1 in 'Unit1.pas' {Form1};

var
  TmpS : String;
  TmpL : String;
begin
  TmpS:=ShortTimeFormat;
  ShortTimeFormat:='24hh:mm';
  TmpL:=LongTimeFormat;
  LongTimeFormat:='24hh:mm';
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
  ShortTimeFormat:=TmpS;
  LongTimeFormat:=TmpL;
end.
Avatar of Motaz

ASKER

I try it but it didn't work. It works only with DateTimeToString function, but it did not affect DateTimePicker

Motaz
I'm afraid I can't help you then, cos that works for me!  It makes EVERYTHING that uses time 24hr and resets it later to the original Windows setting.

Did you actually put it in the Project Source Code?  (It has to be implemented before the controls are created - I think.)

John.
Avatar of Motaz

ASKER

Did you check it with DateTimePicker ?
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hello
did you try ?
Avatar of Motaz

ASKER

Yes it didn't work, I need a 24 hour format for a DateTimePicker and no thing else

Motaz
Avatar of Motaz

ASKER

Thanks Barry, it works.Thanks for your great help