var myformat : TFormatSettings; theDate : TDateTime; begin GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, myformat ); myformat.DateSeparator := '/'; myformat.TimeSeparator := ':'; myformat.ShortDateFormat := 'dd/mm/YYYY hh:nn'; theDate := StrToDateTime( '01/01/2017',myformat); end;
Hope this helps someone.
The inverse is easier:
MyStr := FormatDateTime('dd/mm/yyyy HH:nn:ss',theDate));
[/tab]
[tab title=”Method 2 – Project Jedi”]
If you have the Project Jedi Components JVCL Delphi Jedi you can use the
JvJCLUtils.StrToDateFmt ( 'yyyy/mm/dd', '2017/01/01' );
from the JvJCLUtils.pas file.
[/tab] [/tabs]