Delphi : How to change the date format on both inside the app and globally

I have encountered an issue the other week of a friend that want the default date be changed to another format inside the app. After digging a few days later i came out with a complete list of local settings you can change while inside the delphi environment. Will be posting the codes here for anyone who has encountered the same issues as i have. Hope this helps somebody out there.

Enjoy

Coffee Cup

CurrencyString, CurrencyFormat, NegCurrFormat, ThousandSeparator,
DecimalSeparator, CurrencyDecimals, DateSeparator, ShortDateFormat,
LongDateFormat, TimeSeparator, TimeAMString, TimePMString,
ShortTimeFormat, LongTimeFormat

//Change COMPUTER date and time
SetLocaleInfo(GetThreadLocale, LOCALE_SSHORTDATE, ‘MM/dd/yyyy’);
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0,
SMTO_ABORTIFHUNG, 1000, PDWord(Nil)^);

//Change formatting from within the APPLICATION
DateSeparator := ‘/’;
ShortDateFormat := ‘MM/dd/yyyy’;

Leave a Reply

Your email address will not be published. Required fields are marked *