From RAD Studio API Documentation
Jump to: navigation, search


function DateTimeToStr(const DateTime: TDateTime): string;
function DateTimeToStr(const DateTime: TDateTime;
const AFormatSettings: TFormatSettings): string;


extern DELPHI_PACKAGE System::UnicodeString __fastcall DateTimeToStr(const System::TDateTime DateTime)/* overload */;


Type Visibility Source Unit Parent
function public
System.SysUtils System.SysUtils


Converts a TDateTime value to a string, using the local settings for displaying date and time.

The first form of DateTimeToStr is not thread-safe, because it uses localization information contained in global variables. The second form of DateTimeToStr, which is thread-safe, refers to localization information contained in the AFormatSettings parameter. Before calling the thread-safe form of DateTimeToStr, you must populate AFormatSettings with localization information. To populate AFormatSettings with a set of default locale values, call TFormatSettings.Create.

Attention: When exactly at midnight the DateTimeToStrfunction does not display the time portion. Use DateTimeToString instead to always display the time portion.

See Also

Code Examples