Delphi DateTime Format--What is it?

I have to convert Delphi DateTimes like this 38837.0129173727 to regular date times. What format are Delphi Times in anyway so I can know how to do the conversion?
jbregAsked:
Who is Participating?
 
2266180Connect With a Mentor Commented:
oh. sorry :)
here is a quote from delphi help:
The integral part of a Delphi TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of the TDateTime value is fraction of a 24 hour day that has elapsed.
Following are some examples of TDateTime values and their corresponding dates and times:

0      12/30/1899 12:00 am
2.75      1/1/1900 6:00 pm
-1.25      12/29/1899 6:00 am
35065      1/1/1996 12:00 am
To find the fractional number of days between two dates, simply subtract the two values, unless one of the TDateTime values is negative. Similarly, to increment a date and time value by a certain fractional number of days, add the fractional number to the date and time value if the TDateTime value is positive.
When working with negative TDateTime values, computations must handle time portion separately. The fractional part reflects the fraction of a 24-hour day without regard to the sign of the TDateTime value. For example, 6:00 am on 12/29/1899 is –1.25, not –1 + 0.25, which would be –0.75. There are no TDateTime values between –1 and 0.

Note:      Delphi 1.0 calculated the date from year 1 instead of from 1899. To convert a Delphi 1.0 date to a TDateTime value in later versions of the Delphi language, subtract 693594.0 from the Delphi 1.0 date.
0
 
2266180Commented:
there are some functions to convert delphi date times to system date times: DateTimeToSystemTime or DateTimeToTimeStamp or DateTimeToFileDate and other such functions which you can find in dateutils (D6+)
0
 
jbregAuthor Commented:
I should have prefaced this by saying I can't work within delphi. The Delphi Date times are produced in a text file which I need to parse using ASP / PHP. Therefore I need to actually know and do the conversion myself.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
mikelittlewoodCommented:
Its up to you really how you want to format it.

FormatDateTime('yyyy-mm-dd hh:nn:ss:xxx', 38837.0129173727)  // cant remember the millisecond letter at position xxx sorry off the top of my head

would be one example.
0
 
jbregAuthor Commented:
The FormatDateTime is a delphi function. I can't use that because I am using PHP. I need to understand what this function does and in what format 38837.0129173727 is? Is it seconds since 1979, etc?
0
 
saravananvgCommented:
Hello Sir,

  The DateTime value type holds a date and time. The value may range from 00:00:00 on January 1, 0001 AD to 23:59:59 on December 31, 9999 AD according to the Gregorian Calendar.
 
Internally, the value is stored as a number of 100 nanosecond (0.0000001 second) ticks since 00:00:00 Jan 1 0001 AD.
 
Note: : The MSDN remarks about DateTime gives the start date/time as 01 Jan 0001 12:00:00 midnight.
 
DateTime values are never updated (the value is said to be immutable) - any changes always result in a new DateTime value being returned.
 
Use the TimeSpan to hold a time interval. For example, 2 hours, or 4 days plus 6 hours. A TimeSpan value can be added or subtracted from a DateTime value.
 
DateTime looks very much like a class - in .Net it is called a structure because it is always fixed in size, and can be more efficiently handled. It cannot be inherited from.

In delphi FormatDateTime('dd/mm/yyyy', 38837.0129173727) will give you 30/04/2006, which is similar to what mikelittlewood says.

Hope this information helps you.

with regards,
padmaja.
0
 
Eddie ShipmanAll-around developerCommented:
Ok, everyone, I don't think you've quite gotten what the OP is asking.

He is trying to take a Delphi Datetime, which is an Extended value, stored as text,
and convert it via PHP, to a PHP timestamp.

I have been helping him in the PHP area and hope to have something for him
soon. His PHP DateAdd function is faulty.
0
 
Eddie ShipmanAll-around developerCommented:
Personally, I think this question doesn't belong in the Delphi area and will continue the thread
in the PHP area.
0
 
2266180Commented:
I agree :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.