Jump to content
Registration disabled at the moment Read more... ×
Sign in to follow this  
RTollison

converting string to date time

Recommended Posts

I have a string in an odd format and am needing to change to datetime format.

<DateTime>2021-06-25 08:04:09</DateTime>

 

strtodatetime wants the date to be dd/mm/yyyy time

is there a strtodatetime that uses a formatdatetime option?

Share this post


Link to post
var 
  ldt: TDateTime;
  lFormat: TFormatSettings;
  
begin
  lFormat:= TFormatSettings.Create;
  lformat.DateSeparator:='-';
  lformat.ShortDateFormat:='yyyy-mm-dd';
  ldt:=strtodatetime('2021-06-25 08:04:09', lFormat);
  ShowMessage(DateTimeToStr(ldt));
end;

 

Edited by Lajos Juhász

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×