Recent

Author Topic: Date format set to mm-dd-yyyy  (Read 28515 times)

C#R#

  • New Member
  • *
  • Posts: 40
Re: Date format set to mm-dd-yyyy
« Reply #15 on: January 06, 2015, 03:10:46 pm »
I may be too late, but I included the following code in the initallization section of Form1 and lo, dates the way I am used to.


initialization
  DateSeparator := '.';
  ShortDateFormat := 'd.m.yy';
  LongDateFormat := 'd. mmmm yyyy';     

well, I put this like a first step on Form1.create and get rigth the 'd/m/yy' to datafields on linux.
  DateSeparator := '/';
  ShortDateFormat := 'dd/mm/yyyy';
  LongDateFormat := 'dd/mm/yyyy';     
  Thanks !

lazaron

  • Newbie
  • Posts: 1
  • my avatar
Re: Date format set to mm-dd-yyyy
« Reply #16 on: January 23, 2015, 06:10:21 am »
Thank you. This worked fine, and I could also set two breakpoint (marked * here) to see if the date format was OK.


var ADate:TDateTime;
begin
    ADate:=DBGrid2.DataSource.DataSet.FieldByName('date').Value;

    DateSeparator:='.';
    LongDateFormat:='dd.mm.yyyy';
    ShortDateFormat:='dd.mm.yyyy';
*   d:=DateTimeToStr(ADate);

    DateSeparator:='-';
    LongDateFormat:='yyyy-mm-dd';
    ShortDateFormat:='yyyy-mm-dd';
*   d:=DateTimeToStr(ADate);

end;

garlar27

  • Hero Member
  • *****
  • Posts: 616
Re: Date format set to mm-dd-yyyy
« Reply #17 on: January 23, 2015, 03:37:08 pm »
In some systems from time to time the Format settings are reloaded and overwrite the format configuration you have setted with the system's defaults.

The solution is to put this line in the .lpr (this is not cross-platform):
Code: [Select]
Application.UpdateFormatSettings := FALSE;