Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing dd-mm-jjjj in dd/mm/jjjj

Status
Not open for further replies.

blablabla2

Programmer
Sep 27, 2004
12
0
0
BE
hello,

On my laptop,the date is dd/mm/jjjj. But on my home computer, it is dd-mm-jjjj.

to make my program work on the home computer, I need to force it to write the date as dd/mm/jjjj. How can I do that?

tnx

jeronimo
 
To make the whole application act with another date format, use
Code:
ShortDateFormat := 'yyyy-mm-dd'; // Swedish
in the FormCreate statement...
But be avare... If the system does refresh the date format, or you change the regional settings, the above change will be reset...

If you want to be noticed if this happens. You should create a procedure like this (Maybe not 100% errorfree):
Code:
procedure TForm1.SettingsChange(Sender: TObject; Flag: Integer;
  const Section: string; var Result: Integer);
begin
  if UpperCase(Section) = 'INTL' then
  begin
     if ShortDateFormat <> 'yyyy-mm-dd' then
       ShortDateFormat := 'yyyy-mm-dd';
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnSettingChange := SettingsChange;  
end;


... Or even easier way to wath it....

Use the TApplicationEvents object.
Use the event OnSettingsChange, Sectrion 'intl'


//Nordlund
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top