JavaScript date suffix formatting
<p>I have done my due diligence in investigating this and not had any success yet. Being rather green with JavaScript I am seeking some help. I am wanting to display the date </p>

<pre><code>NOV2012&lt;br&gt;
2&lt;sup&gt;nd&lt;/sup&gt;&lt;br&gt;
5:00 PM
</code></pre>

<p>I have everything working (not my script) except being able to get the date suffix to change to st, nd, rd, or th as the case may be.</p>

<p>This is what I have:</p>

<pre><code>&lt;pre&gt;  &lt;abbr title="Month"&gt;

            &lt;script type="text/javascript"&gt;
                      var d=new Date();
                      var month=new Array(12);
                      month[0]="Jan";
                      month[1]="Feb";
                      month[2]="Mar";
                      month[3]="Apr";
                      month[4]="May";
                      month[5]="Jun";
                      month[6]="Jul";
                      month[7]="Aug";
                      month[8]="Sep";
                      month[9]="Oct";
                      month[10]="Nov";
                      month[11]="Dec";
                      document.write(month[d.getMonth()]);
&lt;/script&gt;&lt;/abbr&gt;  

&lt;script type="text/javascript"&gt;
    var d = new Date()
    document.write(d.getDate())

    ordinal : function (number) {
            var d = number % 10;
            return (~~ (number % 100 / 10) === 1) ? 'th' :
                (d === 1) ? 'st' :
                (d === 2) ? 'nd' :
                (d === 3) ? 'rd' : 'th';
        }
    });
    &lt;/script&gt;
    &lt;sup&gt;%&lt;/sup&gt; 
    &lt;abbr&gt;&lt;script type="text/javascript"&gt;
    var d = new Date()
    document.write(d.getFullYear())
    &lt;/script&gt;&lt;/abbr&gt;
              &lt;sub&gt;

              &lt;script type="text/javascript"&gt;
                      &lt;!--
                      var currentTime = new Date()
                      var hours = currentTime.getHours()
                      var minutes = currentTime.getMinutes()
                      if (minutes &lt; 10){
                      minutes = "0" + minutes
                      }
                      document.write(hours + ":" + minutes + " ")
                      if(hours &gt; 11){
                      document.write("PM")
                      } else {
                      document.write("AM")
                      }
                      //--&gt;
            &lt;/script&gt;

          &lt;/sub&gt;
&lt;/pre&gt;
</code></pre>

<p>I know the issue is with this part:</p>

<pre><code>&lt;pre&gt; 
&lt;script type="text/javascript"&gt;
    var d = new Date()
    document.write(d.getDate())

    ordinal : function (number) {
            var d = number % 10;
            return (~~ (number % 100 / 10) === 1) ? 'th' :
                (d === 1) ? 'st' :
                (d === 2) ? 'nd' :
                (d === 3) ? 'rd' : 'th';
        }
    });


    &lt;/script&gt;

   &lt; sup &gt; % &lt; /sup &gt;
&lt;/pre&gt;
</code></pre>

<p>but I can't seem to work out the right fix. This is where it is sitting:</p>

<p><a href="http://www.bcreativeservices.com/" rel="nofollow">http://www.bcreativeservices.com/</a></p>

<p>Thank you as always.</p>

<p>B</p>
