ok. the function that makes the forum listing (i sent that out to a diff function so i change things once as mcgruff suggested) is this:
Code: Select all
function mkfrmlst($foruminf, $utds, $gmtos){ // make a forum into a table string for display
$forum=$foruminf['title']; $fid=$foruminf['forum_id']; $threads=$foruminf['threads']; // forum info
$lauth=$foruminf['last_post_auth']; $lpt=$foruminf['last_post_time']; # who/when of last post
$lpta=toTimestamp($lpt); $lptd=gmmktime($utds, ($lpta+($gmtos*60*60))); # change to user's time format/zone
$tblln=" <tr><td><a href="forums.php?fid=$fid">$forum</a></td><td>$threads</td><td>$lauth</td><td>$lptd</td></tr>
\n"; # add the row with the forum
echo "<p>test:$utds -> $gmtos<br />$lpt=\$foruminf['last_post_time']; < br />$lpta=toTimestamp($lpt); <br />$lptd=gmmktime
($utds, ($lpta+($gmtos*60*60)));</p>";
return $tblln;
}
and the timestamp:
Code: Select all
function toTimestamp($dateTime){ # turn a mysql datetime into a unix timestamp
$year=substr($dateTime,0,4); $month=substr($dateTime,5,2); $day=substr($dateTime,8,2); # find all the
$hour=substr($dateTime,11,2); $min=substr($dateTime,14,2); $sec=substr($dateTime,17,2); # parts of time
$ts=gmmktime($hour,$min,$sec,$month,$day,$year); # get the unix timestamp
echo "<p>$year=substr($dateTime,0,4); <br />$month=substr($dateTime,5,2); <br />$day=substr($dateTime,8,2); <br />$hour=su
bstr($dateTime,11,2); <br />$min=substr($dateTime,14,2); <br />$sec=substr($dateTime,17,2); <br />$ts=gmmktime($hour,$min,$s
ec,$month,$day,$year);</p>";
return $ts; # return it
}
the echos are there to debug.
i don't get why i'm getting -1 as a result from the toTimestamp function, but i am, as can be seen in this printout from the echos( i think that is what's causing the timestamp instead of display as a result of the gmmktime call):
0000=substr(0000-00-00 00:00:00,0,4);
00=substr(0000-00-00 00:00:00,5,2);
00=substr(0000-00-00 00:00:00,8,2);
00=substr(0000-00-00 00:00:00,11,2);
00=substr(0000-00-00 00:00:00,14,2);
00=substr(0000-00-00 00:00:00,17,2);
-1=gmmktime(00,00,00,00,00,0000);
test:m/d/Y H:i:s -> -5.00
0000-00-00 00:00:00=$foruminf['last_post_time']; < br />-1=toTimestamp(0000-00-00 00:00:00);
1062590357=gmmktime(m/d/Y H:i:s, (-1+(-5.00*60*60)));
when the toTimestamp function worked fine in the testsi used.. so much so that i adjusted the page for someone elseon here to use... as demoed by this that i took from a past backup
Code: Select all
<?php
include("/home/joshua/includes/fyd.incs.php"); # includes file
# this is a test to get utc/gmt times
$metime=date("Y-m-d H:i:s", time());
$gmttime=gmdate("Y-m-d H:i:s", time());
$gmttimestamp=time();
$year=substr($gmttime,0,4);
$month=substr($gmttime,5,2);
$day=substr($gmttime,8,2);
$hour=substr($gmttime,11,2);
$min=substr($gmttime,14,2);
$sec=substr($gmttime,17,2);
$ts=toTimestamp($gmttime);
$fts=gmdate("Y-m-d H:i:s", (toTimestamp($gmttime)+(-8*60*60)));
# forum print choices
$choice01=gmdate("m/d/Y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 13:23:23
$choice02=gmdate("m/d/Y h:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23:23
$choice03=gmdate("m/d/Y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23:23 PM
$choice04=gmdate("m/d/Y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23:23 pm
$choice05=gmdate("D M d Y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 13:23:23
$choice06=gmdate("D M d Y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 01:23:23 PM
$choice07=gmdate("D M d Y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 01:23:23 pm
$choice08=gmdate("m-d-Y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 13:23:23
$choice09=gmdate("m-d-Y h:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 01:23:23
$choice10=gmdate("m-d-Y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 01:23:23 PM
$choice11=gmdate("m-d-Y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 01:23:23 pm
$choice12=gmdate("n/d/Y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 13:23:23
$choice13=gmdate("n/d/Y h:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23:23
$choice14=gmdate("n/d/Y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23:23 PM
$choice15=gmdate("n/d/Y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23:23 pm
$choice16=gmdate("n-d-Y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 13:23:23
$choice17=gmdate("n-d-Y h:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23:23
$choice18=gmdate("n-d-Y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23:23 PM
$choice19=gmdate("n-d-Y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23:23 pm
$choice20=gmdate("m/d/Y H:i", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 13:23
$choice21=gmdate("m/d/Y h:i", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23
$choice22=gmdate("m/d/Y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23 PM
$choice23=gmdate("m/d/Y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23 pm
$choice24=gmdate("D M d Y H:i", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 13:23
$choice25=gmdate("D M d Y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 01:23 PM
$choice26=gmdate("D M d Y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 01:23 pm
$choice27=gmdate("m-d-Y H:i", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 13:23
$choice28=gmdate("m-d-Y h:i", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 01:23
$choice29=gmdate("m-d-Y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23 PM
$choice30=gmdate("m-d-Y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23 pm
$choice31=gmdate("n/d/Y H:i", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 13:23
$choice32=gmdate("n/d/Y h:i", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23
$choice33=gmdate("n/d/Y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23 PM
$choice34=gmdate("n/d/Y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23 pm
$choice35=gmdate("n-d-Y H:i", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 13:23
$choice36=gmdate("n-d-Y h:i", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23
$choice37=gmdate("n-d-Y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23 PM
$choice38=gmdate("n-d-Y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23 pm
$choice39=gmdate("m/d/y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 13:23:23
$choice40=gmdate("m/d/y h:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23:23
$choice41=gmdate("m/d/y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23:23 PM
$choice42=gmdate("m/d/y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23:23 pm
$choice43=gmdate("D M d y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 13:23:23
$choice44=gmdate("D M d y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 01:23:23 PM
$choice45=gmdate("D M d y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 01:23:23 pm
$choice46=gmdate("m-d-y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 13:23:23
$choice47=gmdate("m-d-y h:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 01:23:23
$choice48=gmdate("m-d-y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 01:23:23 PM
$choice49=gmdate("m-d-y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 01:23:23 pm
$choice50=gmdate("n/d/y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 13:23:23
$choice51=gmdate("n/d/y h:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23:23
$choice52=gmdate("n/d/y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23:23 PM
$choice53=gmdate("n/d/y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23:23 pm
$choice54=gmdate("n-d-y H:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 13:23:23
$choice55=gmdate("n-d-y h:i:s", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23:23
$choice56=gmdate("n-d-y h:i:s A", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23:23 PM
$choice57=gmdate("n-d-y h:i:s a", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23:23 pm
$choice58=gmdate("m/d/y H:i", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 13:23
$choice59=gmdate("m/d/y h:i", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23
$choice60=gmdate("m/d/y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23 PM
$choice61=gmdate("m/d/y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # 12/24/1234 01:23 pm
$choice62=gmdate("D M d y H:i", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 13:23
$choice63=gmdate("D M d y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 01:23 PM
$choice64=gmdate("D M d y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # tues dec 24 1234 01:23 pm
$choice65=gmdate("m-d-y H:i", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 13:23
$choice66=gmdate("m-d-y h:i", (toTimestamp($gmttime)+(-5*60*60))); # 12-24-1234 01:23
$choice67=gmdate("m-d-y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23 PM
$choice68=gmdate("m-d-y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23 pm
$choice69=gmdate("n/d/y H:i", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 13:23
$choice70=gmdate("n/d/y h:i", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23
$choice71=gmdate("n/d/y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23 PM
$choice72=gmdate("n/d/y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # 2/24/1234 01:23 pm
$choice73=gmdate("n-d-y H:i", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 13:23
$choice74=gmdate("n-d-y h:i", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23
$choice75=gmdate("n-d-y h:i A", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23 PM
$choice76=gmdate("n-d-y h:i a", (toTimestamp($gmttime)+(-5*60*60))); # 2-24-1234 01:23 pm
#$choice=gmdate("m/d/Y H:i:s", (toTimestamp($gmttime)+(-5*60*60)));
echo <<<END
<html>
<head>
<title>simple time test page</title>
</head>
<body>
<p>my time is: $metime
<br />if this works right, this will be 4 or 5 hours ahead since it's<!--'--> suppossed to be UTC/GMT time: $gmttime
<br />gmt timestamp? $gmttimestamp
</p>
<p>breaking down gmt dateTime
<br /> year: $year
<br /> month: $month
<br /> day: $day
<br /> hour: $hour
<br /> min: $min
<br /> sec: $sec
</p>
<p>toTimeStamp function test (should be the same as above) and switching back to a datetime
<br />$ts
<br />cali's<!--'--> datetime (pst, not pdt): $fts
</p>
<p>choice tests for forums
<br />$choice01
<br />$choice02
<br />$choice03
<br />$choice04
<br />$choice05
<br />$choice06
<br />$choice07
<br />$choice08
<br />$choice09
<br />$choice10
<br />$choice11
<br />$choice12
<br />$choice13
<br />$choice14
<br />$choice15
<br />$choice16
<br />$choice17
<br />$choice18
<br />$choice19
<br />$choice20
<br />$choice21
<br />$choice22
<br />$choice23
<br />$choice24
<br />$choice25
<br />$choice26
<br />$choice27
<br />$choice28
<br />$choice29
<br />$choice30
<br />$choice31
<br />$choice32
<br />$choice33
<br />$choice34
<br />$choice35
<br />$choice36
<br />$choice37
<br />$choice38
<br />$choice39
<br />$choice40
<br />$choice41
<br />$choice42
<br />$choice43
<br />$choice44
<br />$choice45
<br />$choice46
<br />$choice47
<br />$choice48
<br />$choice49
<br />$choice50
<br />$choice51
<br />$choice52
<br />$choice53
<br />$choice54
<br />$choice55
<br />$choice56
<br />$choice57
<br />$choice58
<br />$choice59
<br />$choice60
<br />$choice61
<br />$choice62
<br />$choice63
<br />$choice64
<br />$choice65
<br />$choice66
<br />$choice67
<br />$choice68
<br />$choice69
<br />$choice70
<br />$choice71
<br />$choice72
<br />$choice73
<br />$choice74
<br />$choice75
<br />$choice76
<br />$choice
</p>
<p>hey mikusan, here's<!--'--> the php for you (well.. almost, i can't<!--'--> jsut use the showcode() commandhere because i don't<!--'--> wanna show a specific thing since it's<!--'--> irrelevant to the dispay other than gathering functions)
END;
echo '<br /><?php<br />
# this is a test to get utc/gmt times<br />
<br />
$metime=date("Y-m-d H:i:s", time());<br />
$gmttime=gmdate("Y-m-d H:i:s", time());<br />
$gmttimestamp=time();<br />
$year=substr($gmttime,0,4);<br />
$month=substr($gmttime,5,2);<br />
$day=substr($gmttime,8,2);<br />
$hour=substr($gmttime,11,2);<br />
$min=substr($gmttime,14,2);<br />
$sec=substr($gmttime,17,2);<br />
$ts=toTimestamp($gmttime);<br />
$fts=gmdate("Y-m-d H:i:s", (toTimestamp($gmttime)+(-8*60*60)));<br />
<br />
echo <<<END<br />
<html><br />
<head><br />
<title>simple time test page</title><br />
</head><br />
<body><br />
<p>my time is: $metime<br />
<br />if this works right, this will be 4 or 5 hours ahead since it''s suppossed to be UTC/GMT time: $gmttime<br />
<br />gmt timestamp? $gmttimestamp<br />
</p><br />
<p>breaking down gmt dateTime<br />
<br /> year: $year<br />
<br /> month: $month<br />
<br /> day: $day<br />
<br /> hour: $hour<br />
<br /> min: $min<br />
<br /> sec: $sec<br />
</p><br />
<p>toTimeStamp function test (should be the same as above) and switching back to a datetime<br />
<br />$ts<br />
<br />cali''s datetime (pst, not pdt): $fts<br />
</body><br />
</html><br />
END;<br />
?>';
echo '</body>
</html>';
?>