PDA

View Full Version : Date Conversion


Ryan Johnson
08-25-2001, 02:14 AM
I converted the last 10 posts hack, so I could place it on an ASP page... The problem is, the date is in Unix time. I can't find any code anywhere to make the conversion. It seems like something like this is close, but it's definitely missing something:

CDate("01-01-1970") + (1 / 24 / 60 / 60 * Unix_Date_Here)

Does anyone have the correct formula?

ToraTora!
08-25-2001, 02:45 AM
<a href="http://www.php.net/manual/en/function.date.php" target="_blank">php.net/manual/en/function.date.php</a>

Ryan Johnson
08-25-2001, 03:04 AM
Yes, thanks, but I need to do it without the use of any Perl/PHP functions...

ToraTora!
08-25-2001, 03:42 AM
well, the unix time stamp is a tricky one to convert, however, if you look at my mood hack, it can be done very simply. I worked way to long on that little part to make it that simple, so i am not to inclined to give it away, but all you really need for a good push in the rite direction, is the link i just gave you.

Are you thinking of converting the time stamp using Java? Im not following why you wouldnt use the php standard, for a php hack, with anything else but php.....

Ryan Johnson
08-25-2001, 04:04 AM
OK... I will work on writing it out. I was just hoping someone had already done the work and was willing to share.

I'm placing it on an ASP page.

Ryan Johnson
08-26-2001, 02:13 AM
For anyone who may be wondering... this works:

CStr(CDate("01-01-1970" + (1 / 24 / 60 / 60 * dblUnixDate) - 7))

Replace dblUnixDate with the Unix Time Stamp.

Replace -7 with the time zone offset. The only thing I still have to do is dynamically change the offset for daylight savings. Any ideas?