Results 1 to 17 of 17

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: add 'nd', 'st', 'rd' etc to date

  1. #1
    Default add 'nd', 'st', 'rd' etc to date
    Im looking to add the 'rd' and 'st' etc on the springboard widgets.

    e.g atm it reads 'saturday 3 April' and i want it to say '3rd'

    my current code is this:

    Code:
    <html>
    <head><title>newclock</title></head>
    <style>
    
    
        SPAN#calendar 
    {
            font-family: Helvetica; 
            text-align: center;
            color: #d5d5d5;
             text-shadow: #000000 0px -1px opx;
    }
            
    </style>
    
    <script type="text/javascript">
    function init ( )
    {
      timeDisplay = document.createTextNode ( "" );
      document.getElementById("clock").appendChild ( timeDisplay );
    }
    
    
    function init3 ( )
    {
      timeDisplay = document.createTextNode ( "" );
      document.getElementById("calendar").appendChild ( timeDisplay );
    }
    
    function calendarDate ( )
    {
      var this_weekday_name_array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
      var this_month_name_array = new Array("January","February","March","April","May","June","July","August","September","October","November","December")      //predefine month names
        
      var this_date_timestamp = new Date()    
    
      var this_weekday = this_date_timestamp.getDay()    
      var this_date = this_date_timestamp.getDate()    
      var this_month = this_date_timestamp.getMonth()    
    
      document.getElementById("calendar").firstChild.nodeValue = this_weekday_name_array[this_weekday] + ", " + this_month_name_array[this_month] + " " + this_date  //concat long date string
    }
    
    </script>
    </head>
    
    
    <body bgcolor="black" background="Wallpaper.png">
    <table style="position: absolute; top: 10px; left: 0px; width: 320px; height: 461px;" cellspacing="0" cellpadding="0" align="center">
    <tr align="center" valign="top"  border="0" cellpadding="0">
        <td style="padding-top:12px;" background="datewidget.png" height="60" valign="top">
        <span id="clock">
          <script language="JavaScript">updateClock(); setInterval('updateClock()', 1000 )</script></span><span id="ampm">
            <script language="JavaScript">amPm(); setInterval('amPm()', 1000 )</script>
        </span><br>
    	<span id="calendar">
            <script language="JavaScript">calendarDate(); setInterval('calendarDate()', 1000 )</script>
            </span>
        </td>
    </tr>
    <tr>
        <td align="center" valign="top">
            <span id="calendar">
            <script language="JavaScript">calendarDate(); setInterval('calendarDate()', 1000 )</script>
            </span>
        </td>
    </tr>
    </table>
    
    </body>
    </html>
    Does any1 no good HTML and can add this quick date addon

    bump please
    Last edited by metaljay; 2010-04-04 at 02:34 PM. Reason: Automerged Doublepost


    Like A Boss

  2. #2
    bump pleaseeee


    Like A Boss

  3. #3
    Green Apple
    Join Date
    Oct 2007
    Location
    Kansas City, MO
    Posts
    69
    Thanks
    5
    Thanked 5 Times in 5 Posts

    Try something like this?

    end = "th";
    if (day==1 || day==21 || day==31) end="st";
    if (day==2 || day==22) end="nd";
    if (day==3 || day==23) end="rd";

  4. The Following User Says Thank You to weeslo For This Useful Post:

    metaljay (2010-04-18)

  5. #4

  6. The Following User Says Thank You to santaf For This Useful Post:

    metaljay (2010-04-18)

  7. #5
    Thanks guys, where abouts should I add it in the code?

  8. #6
    Santa Claus, Theme Creator santaf's Avatar
    Join Date
    Feb 2009
    Location
    seattle
    Posts
    3,712
    Thanks
    1,080
    Thanked 1,472 Times in 1,107 Posts

    after it says the var this_date and stuff and before it says the document.get eliment is wehre you place it only wee was wrong instead of day you should put this_date and than at the end of the document.getelement after it says + this_date write in + end

  9. The Following User Says Thank You to santaf For This Useful Post:

    metaljay (2010-04-18)

  10. #7
    Lol sorry but that just confused the hell out of me, can u post the completed code using mine above?

    Sorry

  11. #8
    Santa Claus, Theme Creator santaf's Avatar
    Join Date
    Feb 2009
    Location
    seattle
    Posts
    3,712
    Thanks
    1,080
    Thanked 1,472 Times in 1,107 Posts

    Code:
    <html>
    <head><title>newclock</title></head>
    <style>
    
    
        SPAN#calendar 
    {
            font-family: Helvetica; 
            text-align: center;
            color: #d5d5d5;
             text-shadow: #000000 0px -1px opx;
    }
            
    </style>
    
    <script type="text/javascript">
    function init ( )
    {
      timeDisplay = document.createTextNode ( "" );
      document.getElementById("clock").appendChild ( timeDisplay );
    }
    
    
    function init3 ( )
    {
      timeDisplay = document.createTextNode ( "" );
      document.getElementById("calendar").appendChild ( timeDisplay );
    }
    
    function calendarDate ( )
    {
      var this_weekday_name_array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
      var this_month_name_array = new Array("January","February","March","April","May","June","July","August","September","October","November","December")      //predefine month names
        
      var this_date_timestamp = new Date()    
    
      var this_weekday = this_date_timestamp.getDay()    
      var this_date = this_date_timestamp.getDate()    
      var this_month = this_date_timestamp.getMonth()    
    
      end = "th";
    	if (this_date == 1 || this_date == 21 || this_date == 31) end = "st";
    	if (this_date == 2 || this_date == 22) end = "nd";
    	if (this_date == 3 || this_date == 23) end = "rd";
    
      document.getElementById("calendar").firstChild.nodeValue = this_weekday_name_array[this_weekday] + ", " + this_month_name_array[this_month] + " " + this_date + end //concat long date string
    }
    
    </script>
    </head>
    
    
    <body bgcolor="black" background="Wallpaper.png">
    <table style="position: absolute; top: 10px; left: 0px; width: 320px; height: 461px;" cellspacing="0" cellpadding="0" align="center">
    <tr align="center" valign="top"  border="0" cellpadding="0">
        <td style="padding-top:12px;" background="datewidget.png" height="60" valign="top">
        <span id="clock">
          <script language="JavaScript">updateClock(); setInterval('updateClock()', 1000 )</script></span><span id="ampm">
            <script language="JavaScript">amPm(); setInterval('amPm()', 1000 )</script>
        </span><br>
    	<span id="calendar">
            <script language="JavaScript">calendarDate(); setInterval('calendarDate()', 1000 )</script>
            </span>
        </td>
    </tr>
    <tr>
        <td align="center" valign="top">
            <span id="calendar">
            <script language="JavaScript">calendarDate(); setInterval('calendarDate()', 1000 )</script>
            </span>
        </td>
    </tr>
    </table>
    
    </body>
    </html>
    there you go

  12. The Following User Says Thank You to santaf For This Useful Post:

    metaljay (2010-04-18)

  13. #9
    i think....i love you
    lol

    thanks bro

    you have saved me alot of hassle

    Last edited by metaljay; 2010-04-18 at 01:26 PM.


    Like A Boss

  14. #10
    perma-banned for life
    Join Date
    Mar 2009
    Location
    Photoshop CS5
    Posts
    8,424
    Thanks
    10,454
    Thanked 7,050 Times in 3,590 Posts

    Quote Originally Posted by metaljay View Post
    i think....i love you
    lol

    thanks bro

    you have saved me alot of hassle

    link me to that theme?

  15. #11
    Sorry bro I made a few of the icons (like photos and maps etc)
    and the rest is from a paid theme called

    illumine

  16. #12
    Green Apple
    Join Date
    Oct 2007
    Location
    Kansas City, MO
    Posts
    69
    Thanks
    5
    Thanked 5 Times in 5 Posts

    Quote Originally Posted by santaf View Post
    after it says the var this_date and stuff and before it says the document.get eliment is wehre you place it only wee was wrong instead of day you should put this_date and than at the end of the document.getelement after it says + this_date write in + end
    thx for the correction. My html is very limited. I was just kind of winging it there lol

  17. #13
    perma-banned for life
    Join Date
    Mar 2009
    Location
    Photoshop CS5
    Posts
    8,424
    Thanks
    10,454
    Thanked 7,050 Times in 3,590 Posts

    you should upload your theme

  18. #14
    Santa Claus, Theme Creator santaf's Avatar
    Join Date
    Feb 2009
    Location
    seattle
    Posts
    3,712
    Thanks
    1,080
    Thanked 1,472 Times in 1,107 Posts

    You welcome good job haha :-p and at adroit like original poster said that theme is illumine it's not his own theme and illumine is paid so he can't upload it

  19. #15
    Livin the iPhone Life iNT3Rv3NTiONZz's Avatar
    Join Date
    Feb 2010
    Location
    Cambridge, U.K
    Posts
    1,512
    Thanks
    57
    Thanked 123 Times in 101 Posts

    Hey guys is there any way to make the day, month and date appear in 3 different colours? E.g sunday in dark blue, april in light blue and 13th in white? Plz reply

  20. #16
    Quote Originally Posted by MaxxyBoii2K10 View Post
    Hey guys is there any way to make the day, month and date appear in 3 different colours? E.g sunday in dark blue, april in light blue and 13th in white? Plz reply
    yeh there would be a way,

    Code:
            font-family: Helvetica; 
            text-align: center;
            color: #d5d5d5;
             text-shadow: #000000 0px -1px opx;
    change the 'color: xxxxxx' to what to want and place it between each line of my above code

    (some1 correct me if im wrong here?)




    Quote Originally Posted by santaf View Post
    You welcome good job haha :-p and at adroit like original poster said that theme is illumine it's not his own theme and illumine is paid so he can't upload it
    well i did make some of the icons using his template, notice the photo app is a image of me and my girlfriend, and the maps is my location in the UK :P


    Like A Boss

  21. #17
    Livin the iPhone Life iNT3Rv3NTiONZz's Avatar
    Join Date
    Feb 2010
    Location
    Cambridge, U.K
    Posts
    1,512
    Thanks
    57
    Thanked 123 Times in 101 Posts

    thankyou MetalJay but would you be able to show me where please? im not very good with HTML would be much appreciated!

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