Delphi/Lazarus: Determine System Date Format
Question by Guest | Last update on 2024-01-23 | Created on 2016-04-23
The function FormatDateTime() can be used for converting a TDateTime formatted date into a readable date. For that, you can use the corresponding constants or placeholders such as yyyy/mm/dd and so on.
However, I would like to write a program that can also be used in other countries. And depending on the country, another date formatting is used. For example, the USA is using the format dd/mm/yyyy, Germany is using the dd.mm.yyyy formatting and so on.
So, is there any possibility in Delphi or Lazarus to read out the appropriate format string of the computer on which the application is running?
Related Topics
PHP: Current Date and Time
Tutorial | 0 Comments
VirtualBox: Change Date and Time
Tutorial | 10 Comments
Delphi/Lazarus: Display current Date and Time
Tip | 0 Comments
MySQL: Write current Date or Time into Column
Tutorial | 0 Comments
JavaScript: Get current Date and Time
Tutorial | 1 Comment
PHP: Determine Week Number
Tutorial | 0 Comments
Delphi/Lazarus: 3 Ways to round a Number to X Decimal Places
Tutorial | 7 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Yes. There are the constants ShortDateFormat and ShortTimeFormat. Those variables are always holding the required system formatting.
You can simply use these constants with the function FormatDateTime, for example like that:
In this example, first we only output the date, after that only the time and lastly date and time together.
Last update on 2024-01-23 | Created on 2016-04-23