From Xojo Documentation
New in 2019r2
A DateTime object stores the number of seconds since 12:00 AM, January 1, 1970, i.e., "1970-01-01 00:00:00". Properties of a DateTime enable you to get and set a day value only, a date/time, or only a time.
|The oldest date DateTime can accept is 0001-01-01 00:00.|
To create a DateTime object, you must set date/time you want. You can do this via DateTime.Now or by tasing date/time information to one of the constructors. If you're going to change a date, use DateTime.AddInterval, the + operator, DateTime.SubtractInterval or the - operator as these will handle things like leap years, time zone differences and more.
Because DateTime implements Operator_Compare, you can use the normal comparison operators to compare DateTime values.
If you pass invalid values (such as 32 for the day, 13 for the month) when creating a DateTime, an InvalidArgumentException is raised.
The date properties of FolderItems can be accessed via the CreationDate and ModificationDate properties of FolderItem objects. You can get the current date and time by creating a new date and reading the values of the Year, Month, Day, Hour, Minute, and Second properties.
In the following code:
When using DateTime.ToString with DateTime.FormatStyles to get a formatted date or time, the actual format in which the date or time will appear is affected by the user's operating system settings. The user’s system settings control the ultimate formats that are used.
You can use the DateTime.ToString function to obtain the string value of the date in default system date/time format, i.e., the following gets the string value of the current date/time:
On Windows, the Regional and Language Options panel determines how dates are formatted. On macOS, the date formats are specified in the Languages & Region System Preferences panel.
If you need to control the exact appearance of date/time information, the best way is to extract the information yourself and manage the formatting using string manipulation functions.
This code creates a DateTime object and sets it to 15 April, 2012.
This code displays the current date in a message box.
The following code compares a specific date to the current date:
Var today As DateTime = DateTime.Now
If d < DateTime.Now Then
MessageBox("That's before today!")
If d > today Then
MessageBox("That's after today!")
If d = today Then