2005-02-16 23:51 GMT by AeroSoul

Step #1: Add javascript to page header

Insert this javascript code in the header section (<head></head>), of the page where you want your news to appear.

 <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>

Change the document.write line to customise your output.

Step #2: Modify News Style

Insert this where you want the "posted X days ago" text to appear in your news style.

 <PerlCode>$JSMonth = $TwoDigitMonth--;</PerlCode> 
<script language="javascript">
difference(new Date(<Field: Year>,<Field: JSMonth>,<Field: Day>,<Field: TwoDigitHour>,<Field: Minute>,<Field: Second>));
</script>

Step #3: Full Rebuild

Now, do a Full Rebuild and you're done!

Categories:




Page last modified on February 02, 2009, at 07:26 PM