?
Solved

Delphi DateTime Format--What is it?

Posted on 2006-05-23
9
Medium Priority
?
3,491 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:jbreg
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 16740351
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
 

Author Comment

by:jbreg
ID: 16740363
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
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 16740373
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:jbreg
ID: 16740380
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
 
LVL 28

Accepted Solution

by:
2266180 earned 2000 total points
ID: 16740442
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
 
LVL 6

Expert Comment

by:saravananvg
ID: 16740464
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
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 16744249
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
 
LVL 26

Expert Comment

by:Eddie Shipman
ID: 16744260
Personally, I think this question doesn't belong in the Delphi area and will continue the thread
in the PHP area.
0
 
LVL 28

Expert Comment

by:2266180
ID: 16744319
I agree :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question