PDA

View Full Version : Date Conversion


Ryan Johnson
25 Aug 2001, 03:14
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!
25 Aug 2001, 03:45
php.net/manual/en/function.date.php (http://www.php.net/manual/en/function.date.php)

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

ToraTora!
25 Aug 2001, 04:42
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
25 Aug 2001, 05:04
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
26 Aug 2001, 03:13
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?