As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

I'm lost as to what you're ultimately trying to do. As I see it you're getting this value which holds the number of seconds from 1st Jan 1970, and then converts it to a string. Are you trying to store and output dates since 1st Jan 1970? As far as I know there's no in built Delphi routine to do this (the seconds and 1970 bit anyway) but writing a routine to convert your integer value and add in the offset is pretty easy to do (ask if you want it writing)

The Neil

0

aptalaptalAuthor Commented: 2000-01-24

TheNeil
would you write such a function for me to convert an integer number (holding seconds since 01/01/70 00:00:00 GMT + 0)?

I'll give it a try. Just to avoid confusion, you want a routine that is supplied with the number of seconds since 01/01/70 00:00:00 and returns a string containing the actual date (e.g. given 86461 (1 day 1 minute, and 1 second) it would return 02/01/70 00:01:01 as a string)

<Gulp> What have I gotten myself into now?

The Neil

0

aptalaptalAuthor Commented: 2000-01-24

edey,

i m not dealing with system time. i have the number of seconds from 01/01/70 00:00:00 GMT+0.

MS VC++ 5.0 and ,i guess, older versions of VC++ have 'ctime ' function to convert seconds into a stirng format like :

Hopefully this is what you're after. What it does is tobreak the seconds down into days, hours, minutes, and seconds. It then uses the number of days to calculate the years involved, and finally the months. The complexity comes in in the form of leap years but this handles them (or seems to)

IF days > Day_Count
THEN
BEGIN
Years := Years + 1;
days := days - Day_Count;
END;
UNTIL (Days <= Day_Count);

IF ((Years - 2) MOD 4) = 0 //Is THIS year a leap year?
THEN
BEGIN
IF Days < (31 + 29) //If we HAVEN'T gone past February 29th then we're
THEN //a day short (the above REPEAT loop will have taken
Days := Days + 1; //one too many off) so add a day back on
END;

//Days is now between 1 and 365 (or 366 in the case of a leap year)
Months := 0;
Day_Count := 31;
FOR n := 1 TO 12 //Iterate through the months until we find the one we need
DO //taking days off as we progress through the year
BEGIN
IF (Days <= Day_Count)
THEN
BEGIN
IF Months = 0
THEN
Months := n;
END
ELSE
Days := Days - Day_Count;

Who said I don't like your function? Admittedly I've sworn at you and your family since I spotted appearing ONE MINUTE before mine but it's small, neat, and elegant so you do gain some admiration. It's a bit confusing though and yours might fall over if the date/time format is different while mine will work on any machine (regardless of the date/time format).
Here I was all pleased that I'd got the damn thing working and you pop up with an alternative - grrrrr (I really fancied those points as well)

The Neil =:(

0

aptalaptalAuthor Commented: 2000-01-24

egono,

i tried your code but not working properly.

i gave 948396971, which is expected to display
20/01/2000 19:36:11, to your function .

If you try my code then you'll see that 948396971 does return the correct value. Egono's code works on my machine but I think this may come down to the problem that I highlighted to him - the date/time format is potentially different on different machines.