Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11

Thread: Date Script

  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Script

    Does anyone know where i can get a Java Script for the Date i have one but it doesn't have a position script on it so that i can position it on the site were i want it so does anyone know one that does have a position on it ?

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    welcome jamie

    if you have a date script you are happy with you can use that for the date

    the displayed date will be in a variable and may be displayed using document.write just use innerHTML into a positioned div

    example
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
     var ToDay=new Date();
    
    function ShowDate(){
     document.getElementById('MyDate').innerHTML=Format(ToDay.getDate())+'-'+Format(ToDay.getMonth()+1)+'-'+ToDay.getFullYear();
    }
    
    function Format(v){
     if (v<10){ v='0'+v; }
     return v;
    }
    //-->
    </script></head>
    
    <body onload="ShowDate();" >
    Just change the style to position to your requirement
    <div id="MyDate" style="position:absolute;top:100px;left:100px;width:200px;" ></div>
    </body>
    
    </html>

  • #3
    New Coder
    Join Date
    Jul 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello, thanks for replying and i hope you reply again, the script was brilliant once i put it onto the page it stopped the other script which is the java script for the time i was wondering is it possible to link the scripts up together but have position script inside it so that i can position it.

    Cheers.

  • #4
    New Coder
    Join Date
    Jul 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    please.

  • #5
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,060
    Thanks
    0
    Thanked 13 Times in 13 Posts
    If you can provide your current code or a page we can look at, we'll give it our best...

    -sage-

    P.S. --> Welcome to the forums...
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #6
    New Coder
    Join Date
    Jul 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is the script for the time:

    <BODY onload=clock()><!-- TWO STEPS TO INSTALL BASIC CLOCK:

    1. Add the onLoad event handler into the BODY tag
    2. Copy the coding into the BODY of your HTML document --><!-- STEP ONE: Insert the onLoad event handler into your BODY tag --><!-- STEP TWO: Paste this code into the BODY of your HTML document --><!-- Adjust the placement of the clock in the line below --><SPAN id=pendule style="RIGHT: 312px; POSITION: absolute; TOP: 112px"></SPAN>
    <SCRIPT language=JavaScript>
    <!-- Original: Xavier R. (xav@lougaou.com) -->
    <!-- Modified: Benjamin Wright, Editor -->
    <!-- Web Site: http://www.lougaou.com/ -->

    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->

    <!-- Begin
    function clock() {
    if (!document.layers && !document.all) return;
    var digital = new Date();
    var hours = digital.getHours();
    var minutes = digital.getMinutes();
    var seconds = digital.getSeconds();
    var amOrPm = "AM";
    if (hours > 11) amOrPm = "PM";
    if (hours > 12) hours = hours - 12;
    if (hours == 0) hours = 12;
    if (minutes <= 9) minutes = "0" + minutes;
    if (seconds <= 9) seconds = "0" + seconds;
    dispTime = hours + ":" + minutes + ":" + seconds + " " + amOrPm;
    if (document.layers) {
    document.layers.pendule.document.write(dispTime);
    document.layers.pendule.document.close();
    }
    else
    if (document.all)
    pendule.innerHTML = dispTime;
    setTimeout("clock()", 1000);
    }
    // End -->
    </SCRIPT>
    <!-- Script Size: 1.42 KB -->



    And this is the script for the date



    <!-- ONE STEP TO INSTALL BASIC DATE DISPLAY:

    1. Copy the coding into the BODY of your HTML document -->

    <!-- STEP ONE: Paste this code into the BODY of your HTML document -->

    <BODY>

    <SCRIPT LANGUAGE="JavaScript">

    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->
    <!-- Author: www.cgiscript.net -->

    <!-- Begin

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

    // Array list of days.
    var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','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(today);

    // End -->
    </script>

  • #7
    New Coder
    Join Date
    Jul 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please.

  • #8
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    // by Vic Phillips (08-07-2005) http://www.vicsjavascripts.org.uk
     
    var ToDay=new Date();
    // Array list of days.
    var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
    // Array list of months.
    var months = new Array('January','February','March','April','May','June','July','August','September','October','Novem ber','December');
    
    function ShowDate(){
     ToDay=new Date();
     DS=days[ToDay.getDay()];
     D=Format(ToDay.getDate());
     M=months[ToDay.getMonth()];
     H=ToDay.getHours();
     Mi=Format(ToDay.getMinutes());
     S=Format(ToDay.getSeconds());
     AMPM='AM';
     if (H>11){
      AMPM='PM';
     }
     if (H>12){
      H=H-12;
     }
     H=Format(H);
     Y=ToDay.getFullYear();
     document.getElementById('MyDate').innerHTML=DS+' '+M+' '+D+' '+Y+'<br>'+H+':'+Mi+':'+S+' '+AMPM;
    }
    
    function Format(v){
     if (v<10){ v='0'+v; }
     return v;
    }
    
    setInterval('ShowDate()',1000);
    
    //-->
    </script></head>
    
    <body onload="ShowDate();" >
    Just change the style to position to your requirement
    <div id="MyDate" style="position:absolute;top:100px;left:100px;width:200px;text-Align:center;" ></div>
    </body>
    
    
    </html>

  • #9
    New Coder
    Join Date
    Jul 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello, thanks for the reply and the script the clock and the date are top one one another can you get it so that they are side on and that both have a position setting on it so that i can position it correctly onto the page.

  • #10
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    To save you thinking about it

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    // by Vic Phillips http://www.vicsjavascripts.org.uk
    
     var ToDay=new Date();
    // Array list of days.
    var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
    // Array list of months.
    var months = new Array('January','February','March','April','May','June','July','August','September','October','Novem ber','December');
    
    function ShowDate(){
     ToDay=new Date();
     DS=days[ToDay.getDay()];
     D=Format(ToDay.getDate());
     M=months[ToDay.getMonth()];
     H=ToDay.getHours();
     Mi=Format(ToDay.getMinutes());
     S=Format(ToDay.getSeconds());
     AMPM='AM';
     if (H>11){
      AMPM='PM';
     }
     if (H>12){
      H=H-12;
     }
     H=Format(H);
     Y=ToDay.getFullYear();
     document.getElementById('MyDate1').innerHTML=DS+' '+M+' '+D+' '+Y;
     document.getElementById('MyDate2').innerHTML=H+':'+Mi+':'+S+' '+AMPM;
    }
    
    function Format(v){
     if (v<10){ v='0'+v; }
     return v;
    }
    
    setInterval('ShowDate()',1000);
    
    //-->
    </script></head>
    
    <body onload="ShowDate();" >
    Just change the style to position to your requirement
    <div id="MyDate1" style="position:absolute;top:100px;left:100px;width:200px;text-Align:center;" ></div>
    <div id="MyDate2" style="position:absolute;top:200px;left:200px;width:200px;text-Align:center;" ></div>
    </body>
    
    
    </html>
    and Thank You is good!

  • #11
    New Coder
    Join Date
    Jul 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're a star thank you very much


  •  

    Posting Permissions

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