Forum Moderators: open

Message Too Old, No Replies

Something nice to add to a news article

any ideas how this is done?

         

krez

2:59 pm on Jul 24, 2005 (gmt 0)

10+ Year Member



I am searching for a script for when posting articles on my website i would like to have the feature that various websites use on displaying the time it is posted.

For example if a site is updated with a fresh new article you would see...posted 1 minute ago and if you would return 3 days later you would see.....72 hours and 5 minutes ago. Or just 3 days ago!

I think you know what i mean, it is something that is widely used and would also like to have this kind of feature on my site but don't know how to do this or what kind of script i need to use for this, don't even know how such a script is called.

MichaelBlueJay was so kind to post this:

Actually I guess you could do the entire thing with Javascript. Here's the basic structure:

---------
<HTML><HEAD>
<script type="text/javascript">
function printElapsedTime(startingDate) {
(code to figure the elapsed time goes here)
document.write('Posted ' + elapsedTime + ' days ago');
}
</script>
</HEAD>
<BODY>
<P>blah blah blah
<script type="text/javascript">printElapsedTime('7-20-05')</script>
<P>blah blah blah
</BODY>
</HTML>

I'm going to place different snippets of news articles that are going to be placed on the homepage and from there you can click on the brief description and read the whole story....but how do i make this work for these different short descriptions that are going to be posted on various times, how do i combine this script with brief these descriptions?
(the brief description will be displaying the time ago posted message) :)

krez

6:51 pm on Jul 29, 2005 (gmt 0)

10+ Year Member



If anyone knows something about this subject, please don't be shy to post something :) I would greatly appreciate this!

garyr_h

11:46 pm on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wouldn't this be done easier using PHP and MySQL and just grabbing the time it was posted from the database and compare that time to the current one?

krez

11:59 am on Aug 2, 2005 (gmt 0)

10+ Year Member



If you understand PHP and database methods it would be easier, but when i tried to learn it, a whole "magic box"
of terminologie and all kinds of tutorials that makes my head spin was demotivating me from ever getting this done with this technique.
So in my case javascript would be easier:)