Forum Moderators: coopster

Message Too Old, No Replies

Timestamp conversion

Yay!......

         

theriddla1019

10:57 pm on Feb 6, 2004 (gmt 0)

10+ Year Member



Its me again, been messing around with converting timestamps without much luck, the timestamp for the existing mysql database is (14) or YYYYMMDDHHMMSS
After browsing through a few forum ive messed around with some tidbits but nothing that will work....correctly. Here is what i have now, any pointers would be much appreciated or even the location of a forum that might be what im looking for. (i looked through the WW forums to no avail but ya never know what you can miss not thinking of certain keywords.)

Snippet:

<?
$Query="SELECT User, Title, UNIX_TIMESTAMP(Entry) as your_date FROM communicationdata";
$Result=mysql_query($Query, $Link);
$num=mysql_numrows($Result);

mysql_close();

$i=0;
$a=0;
while ($i < $num and $a < 17) {

$Title=mysql_result($Result,$i,"Title");
$User=mysql_result($Result,$i,"User");
$Entry = date("F jS, Y", $Row['your_date']);
echo "$User - $Title - $Entry <br>";

++$i;
++$a;
}
?>

can anyone see what i might be doing wrong?
any help would be much appreciated :)
Oh yeah what this code is doing wrong is
every item is returning the date January, 1st 1970
when none of the values are remotely close to 1970 and or january.

Timotheos

11:54 pm on Feb 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



every item is returning the date January, 1st 1970

That's the beginning of time according to Unix. So it means your $Row['your_date'] is always zero.

I can't see where you're setting $Row['your_date'] with mysql_fetch_array. Did you snip it out of the snippet?

theriddla1019

3:46 pm on Feb 25, 2004 (gmt 0)

10+ Year Member



Wow your right, im using $Row and im not even setting $Row ... sometimes i amaze myself on the things i miss.

So Im Guessing i should be doing something like this?

$Entry=mysql_result($Result,$i,"your_date");
$EntryFull = date("F jS, Y", $Entry);

theriddla1019

3:57 pm on Feb 25, 2004 (gmt 0)

10+ Year Member



Yup that worked

Thanks for the insight Timotheos!

TheRiddla..