Jump to content
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×