Hi All
I want to change format of system Time display by my program
for example if format of system time is "hh:mm:ss AM"(12 hour clock format) I want to change it to "HH:mm:ss"(24 hour clock format)
is any solution for this purpose?
thanks

Do you mean that you want to show a clock on your app? And you want to format the time in some way other than TimeToStr() ?

If so then use the following from sysutils:
function FormatDateTime(const Format: string;
DateTime: TDateTime): string;

If the format is hh:nn:ss it will use 24 hour time.

I hope that helps,

Mark

thankyou my frend
it is a good method for changing time format
but i need to an instruction that change format of system time that runing application be caus to changing windows time format

Member Avatar for Micheus

thankyou my frend
it is a good method for changing time format
but i need to an instruction that change format of system time that runing application be caus to changing windows time format

You must to use SetLocaleInfo function from Win32 API.


ex.:

procedure SetTimeFormat(tfType24 :Boolean)
var
  Changed :Boolean;
  LCID :LongInt;
begin
  LCID := GetSystemDefaultLCID;
  if ftType24 then  // if format type is 24 hours...
    Changed := SetLocaleInfo(LCID, LOCALE_STIMEFORMAT, 'HH:mm:ss')
  else  // if format type is 12 hours AM/PM
    Changed := SetLocaleInfo(LCID, LOCALE_STIMEFORMAT, 'hh:mm:ss');

   if Changed then  // if no error then notify all app that settings changed
     SendMessage(HWND_TOPMOST, WM_SETTINGCHANGE, 0, 0);
 end;

bye.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.