Created
January 8, 2023 19:12
-
-
Save an01f01/f99b096f466af2e1ebc0a13d6d926108 to your computer and use it in GitHub Desktop.
This is a short example on how to quickly format a current day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uses | |
System.DateUtils; | |
procedure FormatDateToString(): string; | |
var | |
CurrentDate: TDateTime; | |
FmtStngs: TFormatSettings; | |
begin | |
{ As a bonus using IncDay will get you any day from current date, such as yesterday would be IncDay(Now, -1) } | |
CurrentDate := IncDay(Now, 0); | |
FmtStngs := TFormatSettings.Create('en-US'); | |
FmtStngs.ShortDateFormat := 'yyyy-MM-dd'; | |
Result := DateToStr(CurrentDate, FmtStngs); | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment