var MySettings: TFormatSettings; s: string; d: TDateTime; begin GetLocaleFormatSettings(GetUserDefaultLCID, MySettings); MySettings.DateSeparator := '-'; MySettings.TimeSeparator := ':'; MySettings.ShortDateFormat := 'mm-dd-yyyy'; MySettings.ShortTimeFormat := 'hh:nn:ss'; s := DateTimeToStr(Now, MySettings); ShowMessage(s); d := StrToDateTime(s, MySettings); ShowMessage(DateTimeToStr(d, MySettings)); end;
Friday, December 30, 2011
How to format strtodatetime in delphi
Because of regional setting computer that depend on each computer, it will output format time as regional setting. If we want to format datetime as we want regardless regional setting, we can write the script as below :
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment