SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with this code - configuring day-month

    Hi all - I have the following code and it works fine for what I'm using it for, but I'm not proficient in Javascript or jQuery. The way the code is set up right now it shows the day followed by month of the year. I would like to flip it so the month shows first followed by the day. This would seem simple to do for someone who knows what their doing, and in this case that ain't me I do however, believe it has to do with ' ' + cdday + ' ' + monthnames[parseInt(cdmonth,10)]), I just don't know how to flip the code without messing it up!

    If anyone has any suggestions on how to add the 'Year' that would be appreciated as well!

    Here's the code:

    Code:
    <div id="dtirpsb">
    <script style="text/javascript">
    function showrecentposts(json) {
    
      for (var i = 0; i < numposts; i++) {
        var entry = json.feed.entry[i];
        var posttitle = entry.title.$t;
        var posturl;
        if (i == json.feed.entry.length) break;
        for (var k = 0; k < entry.link.length; k++) {
          if (entry.link[k].rel == 'alternate') {
            posturl = entry.link[k].href;
            break;
          }
        }
        posttitle = posttitle.link(posturl);
        var readmorelink = "&raquo;&raquo;";
        readmorelink = readmorelink.link(posturl);
        var postdate = entry.published.$t;
        var cdyear = postdate.substring(0,4);
        var cdday = postdate.substring(8,10);
        var cdmonth = postdate.substring(5,7);
        var monthnames = new Array();
        monthnames[1] = "January";
        monthnames[2] = "February";
        monthnames[3] = "March";
        monthnames[4] = "April";
        monthnames[5] = "May";
        monthnames[6] = "June";
        monthnames[7] = "July";
        monthnames[8] = "August";
        monthnames[9] = "September";
        monthnames[10] = "October";
        monthnames[11] = "November";
        monthnames[12] = "December";
        if ("content" in entry) {
          var postcontent = entry.content.$t;}
        else
        if ("summary" in entry) {
          var postcontent = entry.summary.$t;}
        else var postcontent = "";
        var re = /<\S[^>]*>/g;
        postcontent = postcontent.replace(re, "");
        if (!standardstyling) document.write('');
           document.write('<div class="bbrecpost2">');
        document.write('<span>');
        if (standardstyling) document.write('');
    
        document.write(posttitle);
        if (standardstyling) document.write('');
           document.write('<br/>');
        if (showpostdate == true) document.write(' ' + cdday + ' ' + monthnames[parseInt(cdmonth,10)]);
        if (!standardstyling) document.write('<div class="bbrecpostsum"">');
        if (standardstyling) document.write('');
        if (showpostsummary == true) {
          if (standardstyling) document.write('');
          if (postcontent.length < numchars) {
             if (standardstyling) document.write('<i>');
             document.write(postcontent);
             if (standardstyling) document.write('</i>');}
          else {
             if (standardstyling) document.write('<i>');
             postcontent = postcontent.substring(0, numchars);
             var quoteEnd = postcontent.lastIndexOf(" ");
             postcontent = postcontent.substring(0,quoteEnd);
             document.write(postcontent + '... ' + readmorelink);
             if (standardstyling) document.write('</i>');}
    }
        if (!standardstyling) document.write('</div>');
                          document.write('</span>');
                         document.write('</div>');
        if (standardstyling) document.write('');
    }
    if (!standardstyling) document.write('<div class="bbwidgetfooter">');
    if (standardstyling) document.write('');
    document.write('');
    if (!standardstyling) document.write('/div');
    
    }
    </script>
    
    <script style="text/javascript">
    var numposts = 10;
    var showpostdate = true;
    var showpostsummary = false;
    var numchars = 100;
    var standardstyling = true;
    </script>
    
    <script src="http://www.movienewsplus.com/feeds/posts/default?orderby=published&alt=json-in-script&callback=showrecentposts">
    </script>
    </div>
    
    <noscript>Oops! Make sure JavaScript is enabled in your browser.</noscript>
    
    <style type=text/css>
    #rpdr {
    background: url( http://3.bp.blogspot.com/-WM-QlPmHc6Y/T5wJV58qj9I/AAAAAAAACAk/1kULxdNyEyg/s1600/blogger.png ) 0px 0px no-repeat; padding: 1px 0px 0px 19px;
    height:14px;
    margin: 5px 0px 0px 0px;
    line-height:14px;
    }
    
    #rpdr, #rpdr a
    {
    a{font-size:12px;text-decoration:none;font-weight:bold;color:#33CCFF}
    }
    
    #dtirpsb { }
    
    .bbrecpost2 {
    padding-top:6px;
    padding-bottom:15px;
    font-size:12px;text-decoration:none;font-weight:normal;color:#404040
    }
    
    .bbrecpost2 a{font-size:12px;text-decoration:none;font-weight:bold;color:#1CBFF2
    }
    
    .bbrecpost2 a:hover {
    text-decoration:none;
    color: 0db4e7;
    }
    </style>

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,489
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    replace

    Code:
        if (showpostdate == true) document.write(' ' + cdday + ' ' + monthnames[parseInt(cdmonth,10)]);

    with
    Code:
        if (showpostdate == true) document.write(' ' + monthnames[parseInt(cdmonth,10)]+' '+cdday);

  3. #3
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That did it..Thank you for your time Vic!


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
  •