Moderator: Spunkmeyer
<PerlCode>
$consider_new = time() - (30 * (60*60*24));
if ($newstime > $consider_new){
</PerlCode>
<IMG SRC="/images/new.gif" WIDT="30" HEIGTH="15">
<PerlCode>
}
</PerlCode>
<PerlCode>
$newshtml .= int ((time() - $newstime)/86400);
</PerlCode>
<script language="javascript>function difference(oldtime) {
var nowtime = new Date();
var milliseconds1 = oldtime.getTime();
var milliseconds2 = nowtime.getTime();
var difference = milliseconds2 - milliseconds1;
var daysDifference = Math.floor(difference/1000/60/60/24);
difference = difference - daysDifference*1000*60*60*24
var hoursDifference = Math.floor(difference/1000/60/60);
difference = difference - hoursDifference*1000*60*60
var minutesDifference = Math.floor(difference/1000/60);
difference = difference - minutesDifference*1000*60
var secondsDifference = Math.floor(difference/1000);
document.write('This topic is ' + daysDifference + ' days, ' + hoursDifference + ' hours, ' + minutesDifference + ' minutes, ' + secondsDifference + ' and seconds old.');
}
</script>
<PerlCode>$JSMonth = $TwoDigitMonth--;</PerlCode><script language="javascript">
difference(new Date(<Field: Year>,<Field: JSMonth>,<Field: Day>,<Field: TwoDigitHour>,<Field: Minute>,<Field: Second>));</script>
<script language="javascript>function diff(oldtime) {
var nowtime = new Date();
var milliseconds1 = oldtime.getTime();
var milliseconds2 = nowtime.getTime();
var diff = milliseconds2 - milliseconds1;
var daysDiff = Math.floor(diff/1000/60/60/24);
diff = diff - daysDiff*1000*60*60*24
var hoursDiff = Math.floor(diff/1000/60/60);
document.write('This topic is '
+ (daysDiff>0 ? daysDiff + ' days': '')
+ (daysDiff<1 && hoursDiff>6 ? hoursDiff + ' hours': '')
+ ' old.');
}
</script>
InSAnE NiNjA wrote:
- Code: Select all
<script language="javascript>function diff(oldtime) {
var nowtime = new Date();
var milliseconds1 = oldtime.getTime();
var milliseconds2 = nowtime.getTime();
var diff = milliseconds2 - milliseconds1;
var daysDiff = Math.floor(diff/1000/60/60/24);
diff = diff - daysDiff*1000*60*60*24
var hoursDiff = Math.floor(diff/1000/60/60);
document.write('This topic is '
+ (daysDiff>0 ? daysDiff + ' days': '')
+ (daysDiff<1 && hoursDiff>6 ? hoursDiff + ' hours': '')
+ ' old.');
}
</script>
i'm tired but with that..
after 6 hours it will display hours up to 23, after 1 day it will only display days.
just a rewrite and shortening..
<script language="javascript>function difference(oldtime) {
var nowtime = new Date();
var milliseconds1 = oldtime.getTime();
var milliseconds2 = nowtime.getTime();
var difference = milliseconds2 - milliseconds1;
var daysDifference = Math.floor(difference/1000/60/60/24);
difference = difference - daysDifference*1000*60*60*24
var hoursDifference = Math.floor(difference/1000/60/60);
difference = difference - hoursDifference*1000*60*60
var minutesDifference = Math.floor(difference/1000/60);
difference = difference - minutesDifference*1000*60
var secondsDifference = Math.floor(difference/1000);
// document.write('This topic is ' + daysDifference + ' days, ' + hoursDifference + ' hours, ' + minutesDifference + ' minutes, and ' + secondsDifference + ' seconds old.');
if (daysDifference > 1 && hoursDifference > 6)
document.write('This topic is ' hoursDifference + ' hours, and ' + minutesDifference + ' minutes old.');
}
</script>
<script language="javascript">
function difference(oldtime) {
var nowtime = new Date();
var milliseconds1 = oldtime.getTime();
var milliseconds2 = nowtime.getTime();
var difference = milliseconds2 - milliseconds1;
var daysDifference = Math.floor(difference/1000/60/60/24);
difference = difference - daysDifference*1000*60*60*24
var hoursDifference = Math.floor(difference/1000/60/60);
difference = difference - hoursDifference*1000*60*60
var minutesDifference = Math.floor(difference/1000/60);
difference = difference - minutesDifference*1000*60
var secondsDifference = Math.floor(difference/1000);
if (daysDifference < 1 && hoursDifference < 4)
document.write(' (<span class="lastupdated"><b>' + hoursDifference + ' </b> hours, <b> ' + minutesDifference + ' </b> minutes ago)');
else if (daysDifference < 1 && hoursDifference >= 4 && hoursDifference < 20)
document.write(' (<span class="lastupdated"><b>' + hoursDifference + ' </b> hours ago)');
else (daysDifference >= 1)
document.write(' ');
}
</script>
Users browsing this forum: No registered users and 1 guest