Welcome to TalkGraphics.com
Results 1 to 10 of 26

Threaded View

  1. #1
    Join Date
    Oct 2003
    Location
    Kettering, Northamptonshire, UK
    Posts
    48

    Unhappy Dynamic Date Script

    Hi Folks. I'm returning to Web Designer after a few years away and I'm in the middle of designing a fairly straightforward site.

    Historically, I've always had a bit of javascript code (that I've copied and pasted from my previous web creations and that I found somewhere on the 'net) that simply shows the day/date - and it changes daily to automagically to show the current day/date.

    I came to use it on my new site and decided I needed to align the text to the right. Does anyone know what I need to add to the code to allow me to 'align it right'?

    Thanks in advance!

    <style>
    .mydate {
    font: 10px arial;
    color: white;
    }
    </style>
    <SCRIPT LANGUAGE="Javascript"><!--

    // Get today's current date.
    var now = new Date();

    // Array list of days.
    var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thu rsday','Friday','Saturday');

    // Array list of months.
    var months = new Array('January','February','March','April','May',' June','July','August','September','October','Novem ber','December');

    // Calculate the number of the current day in the week.
    var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

    // Calculate four digit year.
    function fourdigits(number) {
    return (number < 1000) ? number + 1900 : number;
    }

    // Join it all together
    today = days[now.getDay()] + ", " +
    months[now.getMonth()] + " " +
    date + ", " +
    (fourdigits(now.getYear())) ;

    // Print out the data.
    document.write('<span class="mydate">' + today + '</span>');
    //--></SCRIPT>
    Last edited by SteveP; 30 August 2016 at 06:07 AM. Reason: typo in code
    Thanks

    Steve
    Kettering UK

 

 

Tags for this Thread

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
  •