Name
TDateTime Type
Syntax
type TDateTime = type Double;
Description
The TDateTime type stores a date and time as the
number of days since the start of the day on December 30, 1899, which
is the standard used in OLE automation. The integer part is the
number of days, and the fractional part specifies the time of day.
Tips and Tricks
TDateTimedoes not store a time zone, so if you want to record a date and time in a file or database, you should convert the local time to UTC (Coordinated Universal Time). When loading the date and time from the file or database, convert back to local time. That lets users work in different time zones without running into problems.You can count the number of days between two
TDateTimevalues by subtracting, and converting the result to an integer. Whether you round off or truncate depends on the circumstances. Do you want to count the number of “days” between 1:00 A.M. on March 3 to 11:00 P.M. on March 4 as one day (truncate) or two days (round off)?Unix represents a date and time as the number of seconds since midnight January 1, 1970 UTC. If a file or database contains a Unix time, you can convert it to a Delphi
TDateTimeby dividing bySecsPerDayand then adding 25569. That gives you the UTC date and time; you must convert this to a local date and time before using it in most Delphi programs.
Example
// Convert a local time to UTC by adding the time zone bias. // To convert from UTC back to local, subtract the bias. function LocalToUTC(DateTime: TDateTime): ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access