Results 1 to 3 of 3

Thread: Count Up Script

  1. #1
    Join Date
    Dec 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Count Up Script

    Hello

    I'm hoping someone can assist me. I'm looking for a Count Up Script which I can use on a New Ticker page which counts from the day the message was published (i.e. starts with "Today" when published, changes to "Yesterday" the next day "2 Days Ago", "1 Week Ago" etc.

    Dynamic Drive has a Count up Script but has Minutes, hours and seconds which I don't require. Would this be suitable for what I'm looking for and if so how could I modify

    Any advice appreciated

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,933
    Thanks
    16
    Thanked 303 Times in 302 Posts
    Blog Entries
    9

    Default

    What exactly is a "news ticker" page?

    And how are you recording the publication date? Is that something which is stored in a database? Of maybe a last modified timestamp of a news entry file? Or the pubDate from an RSS feed? Or a static variable saved/written on the page itself?

    This type of thing is usually easier and more accurate being calculated on the server side, so PHP would probably be the way to go. Is your server setup to run PHP? Assuming it is, these functions should do what you ask http://css-tricks.com/snippets/php/time-ago-function/

    If you need more help, please provide a link to your page and give more information about how news dates/entries are being stored.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,781
    Thanks
    2
    Thanked 415 Times in 409 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    <span id="posted" ></span>
    
    
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function zxcDaysPosted(o){
     var obj=document.getElementById(o.ID),p=o.Date,p=typeof(p)=='string'?p.split(/\D/):[],d,w;
     if (obj&&isFinite(p[0])&&isFinite(p[1])&&isFinite(p[2])){
      d=Math.floor((new Date()-new Date(p[0],p[1]-1,p[2]))/(1000*60*60*24));
      w=Math.floor(d/7);
      obj.innerHTML=w+' Weeks '+(d-(w*7))+' Days';
      o.to=setTimeout(function(){ zxcDaysPosted(o); },60000);
     }
    }
    
    zxcDaysPosted({ID:'posted',Date:'2014-04-22'});
    
    /*]]>*/
    </script>
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Similar Threads

  1. Count Up Script?
    By F0u4d in forum JavaScript
    Replies: 16
    Last Post: 05-28-2012, 04:49 AM
  2. Count up script?
    By atomic7732 in forum PHP
    Replies: 7
    Last Post: 12-23-2010, 01:04 AM
  3. Looking for a count up script
    By darmie_a_Phoenix in forum Dynamic Drive scripts help
    Replies: 24
    Last Post: 03-22-2010, 06:08 PM
  4. Count down script
    By Scrounger in forum Dynamic Drive scripts help
    Replies: 9
    Last Post: 08-08-2007, 09:29 PM
  5. Count Down Script
    By kjenkins in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 12-10-2004, 09:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •