How do I add today's date to website?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • doug145
    Sergeant First Class

    • Sep 2006
    • 56

    #16
    Re: How do I add today's date to website?

    Can anyone still help me on my last question? I need a javascript that will add 28 days to today's date and display it.

    Doug

    Comment

    • navaldesign
      General & Forum Moderator

      • Oct 2005
      • 12080

      #17
      Re: How do I add today's date to website?

      Please note that the 28 days calendar doen't simply add 28 days to the present date. The 28 days calendar is based on a 13 month (instead of 12) basis, which makes 28X13=364 plus one "Rest "day. And, it is counted from a reference date. So if you want to display the 28 say calendar correctly, you need to have that reference date.
      Navaldesign
      Logger Lite: Low Cost, Customizable, multifeatured Login script
      Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
      DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
      Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

      Comment

      • doug145
        Sergeant First Class

        • Sep 2006
        • 56

        #18
        Re: How do I add today's date to website?

        I do not care about a 28 days calendar. (It was only by coincidence that I said 28, but that may change for me anyway). I may as well be trying to add 11 days, or 16 days, or 55 days for that matter. Just give me an example where ANY NUMBER of days are added to today's date and that new date is displayed.

        Doug

        Comment

        • navaldesign
          General & Forum Moderator

          • Oct 2005
          • 12080

          #19
          Re: How do I add today's date to website?

          Ok, i'll figure out something for you. Let you know tomorrow. Must it be Javascript or can it be server side (php) ? Please note that if it is php, you need to publish your pages as php
          Navaldesign
          Logger Lite: Low Cost, Customizable, multifeatured Login script
          Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
          DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
          Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

          Comment

          • doug145
            Sergeant First Class

            • Sep 2006
            • 56

            #20
            Re: How do I add today's date to website?

            Just some javascript that I can set right on my page is all I need.

            Doug

            Comment

            • doug145
              Sergeant First Class

              • Sep 2006
              • 56

              #21
              Re: How do I add today's date to website?

              Navaldesign,

              Just wondered if you might have a script for me yet. Your help is appreciated.

              Doug

              Comment

              • navaldesign
                General & Forum Moderator

                • Oct 2005
                • 12080

                #22
                Re: How do I add today's date to website?

                Working on it. It is harder to do if you need a variable number of days, as it has to take care also of 1. Day change (F.e. if you want a 8 day difference, Monday should become Tuesday, if you need a 10 days difference, Monday should become Thirsday and so on) 2. Month change (you need to check if the month changes f.e. adding 28 days to September 4 makes it October 2, whilst adding 28 days to October 4 makes it November 3: depends on the month days, which are variable 28,29,30,31) 3. Year change (adding 15 days to 20 December 2006 makes it January 4 2007)

                I think i'll make it, just give me some time.
                Navaldesign
                Logger Lite: Low Cost, Customizable, multifeatured Login script
                Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                Comment

                • doug145
                  Sergeant First Class

                  • Sep 2006
                  • 56

                  #23
                  Re: How do I add today's date to website?

                  Here is an example of adding 5 days, but I cannot get it to work in Blue Voda:

                  // Get today's date
                  Calendar now = Calendar.getInstance();
                  Calendar working;
                  SimpleDateFormat formatter = new SimpleDateFormat("E yyyy.MM.dd 'at' hh:mm:ss a zzz");

                  working = (Calendar) now.clone();
                  working.add(Calendar.DAY_OF_YEAR, + 5);
                  prt(" In five days it will be: " + formatter.format(working.getTime()));

                  prt();

                  }

                  Comment

                  • navaldesign
                    General & Forum Moderator

                    • Oct 2005
                    • 12080

                    #24
                    Re: How do I add today's date to website?

                    Here is something simple. It can work for positive differences up to 31 days, but it will not work correctly if the new date goes over 28 February and, in the same time, February has 29 days. Since this is going to happen in 2008, you have more than one year to find another solution. Copy the code and simply paste it in a html box in your page. Then place the html box anywhere you want it in your page. To edit the days period, edit the number in RED

                    <form name=myForm2>
                    <input type=button value="Loading..." name=clock></form>
                    <SCRIPT LANGUAGE="JavaScript"><!--
                    function runClock(){
                    theTime = window.setTimeout("runClock()", 1000);
                    d = new Date();
                    mon = d.getMonth();
                    date = d.getDate();
                    year = d.getYear();
                    hr = d.getHours();
                    min = d.getMinutes();
                    sec = d.getSeconds();

                    diff = 25
                    date2 = date;
                    date+=diff;
                    monthdays = new Array();
                    monthdays = [31,28,31,30,31,30,31,31,30,31,30,31];
                    if(date>monthdays[mon]){date-=monthdays[mon] ; mon+=1}
                    if (mon>13) {mon-=12 ; year+=1}



                    if(year<1000){year=(""+(year+11900)).substring(1,5 );}
                    else{year=(""+(year+10000)).substring(1,5);}
                    if(hr==0){ap=" AM";hr=12}
                    else if(hr <= 11){ap=" AM"}
                    else if(hr == 12){ap=" PM";hr=12}
                    else if(hr >= 13){ap=" PM";hr-=12}
                    if(min <= 9){min="0"+min}
                    if(sec <= 9){sec="0"+sec}

                    zmon=new Array();
                    zmon=["January","February","March","April","May","Ju ne", "July","August","September","October","Novembe r"," December"];

                    document.myForm2.clock.value=""+zmon[mon]+" "+date+", "+year+" "+hr+":"+min+":"+sec+ap+"";}
                    runClock();
                    //--></script>
                    Navaldesign
                    Logger Lite: Low Cost, Customizable, multifeatured Login script
                    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                    Comment

                    • doug145
                      Sergeant First Class

                      • Sep 2006
                      • 56

                      #25
                      Re: How do I add today's date to website?

                      NavalDesign: THANK YOU so much! Just what I was looking for.

                      Doug

                      Comment

                      • doug145
                        Sergeant First Class

                        • Sep 2006
                        • 56

                        #26
                        Script is not crossing into the new year correctly

                        Hi Navaldesign,

                        The script you gave me has been working fine until now. But it is not working now because it has to cross into January of next year with its date difference. The proper date is not displaying now. Could you please look at the script again and correct it so it will display the right date in January? It looks like you put code in to take care of yearly crossovers, but it is not working right.

                        Doug

                        Comment

                        • navaldesign
                          General & Forum Moderator

                          • Oct 2005
                          • 12080

                          #27
                          Re: How do I add today's date to website?

                          Can you please provide me with a link to the page with the script ?
                          Navaldesign
                          Logger Lite: Low Cost, Customizable, multifeatured Login script
                          Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                          DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                          Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                          Comment

                          • doug145
                            Sergeant First Class

                            • Sep 2006
                            • 56

                            #28
                            Re: How do I add today's date to website?

                            I temporarily removed it from the page since is was not working.

                            If you would, just create a blank web page and do a create HTML box and preview it from there?

                            Here is the code I have:

                            <form name=myForm2>
                            <input type=button value="Loading..." name=clock></form>
                            <SCRIPT LANGUAGE="JavaScript"><!--
                            function runClock(){
                            theTime = window.setTimeout("runClock()", 1000);
                            d = new Date();
                            day = d.getDay();
                            mon = d.getMonth();
                            date = d.getDate();
                            year = d.getYear();
                            hr = d.getHours();
                            min = d.getMinutes();
                            sec = d.getSeconds();
                            diff = 14
                            date2 = date;
                            date+=diff;
                            monthdays = new Array();
                            monthdays = [31,28,31,30,31,30,31,31,30,31,30,31];
                            if(date>monthdays[mon]){date-=monthdays[mon] ; mon+=1}
                            if (mon>13) {mon-=12 ; year+=1}
                            if(year<1000){year=(""+(year+11900)).substring(1,5 );}
                            else{year=(""+(year+10000)).substring(1,5);}
                            if(hr==0){ap=" AM";hr=12}
                            else if(hr <= 11){ap=" AM"}
                            else if(hr == 12){ap=" PM";hr=12}
                            else if(hr >= 13){ap=" PM";hr-=12}
                            if(min <= 9){min="0"+min}
                            if(sec <= 9){sec="0"+sec}
                            zmon=new Array();
                            zmon=["January","February","March","April","May","Ju ne", "July","August","September","October","Novembe r"," December"];
                            zday=new Array();
                            zday=["Sunday","Monday","Tuesday","Wednesday","Thurs day" ,"Friday","Saturday"];
                            document.myForm2.clock.value="Fourteen days from now will be "+zday[day]+", "+zmon[mon]+" "+date+", "+year+"";}
                            runClock();
                            //--></script>

                            Thanks!

                            Doug

                            Comment

                            • doug145
                              Sergeant First Class

                              • Sep 2006
                              • 56

                              #29
                              Re: How do I add today's date to website?

                              Guess no one is around to answer me on this. It should resolve itself come Jan 1. Anyone is invited to reply though, if you have nothing else to do for the next few days.

                              Comment

                              • navaldesign
                                General & Forum Moderator

                                • Oct 2005
                                • 12080

                                #30
                                Re: How do I add today's date to website?

                                Sorry, my mistake. The Months numbering for the script starts from 0, so the correct script should be as follows:

                                <form name=myForm2>
                                <input type=button value="Loading..." name=clock></form>
                                <SCRIPT LANGUAGE="JavaScript"><!--
                                function runClock(){
                                theTime = window.setTimeout("runClock()", 1000);
                                d = new Date();
                                day = d.getDay();
                                mon = d.getMonth();
                                date = d.getDate();
                                year = d.getYear();
                                hr = d.getHours();
                                min = d.getMinutes();
                                sec = d.getSeconds();
                                diff = 14
                                date2 = date;
                                date+=diff;
                                monthdays = new Array();
                                monthdays = [31,28,31,30,31,30,31,31,30,31,30,31];
                                mon1 = mon
                                if(date>monthdays[mon1]){mon+=1}
                                if(date>monthdays[mon1]){date-=monthdays[mon1]}
                                if(mon>11){year+=1}
                                if(mon>11){mon-=12}
                                if(year<1000){year=(""+(year+11900)).substring(1,5 );}
                                else{year=(""+(year+10000)).substring(1,5);}
                                if(hr==0){ap=" AM";hr=12}
                                else if(hr <= 11){ap=" AM"}
                                else if(hr == 12){ap=" PM";hr=12}
                                else if(hr >= 13){ap=" PM";hr-=12}
                                if(min <= 9){min="0"+min}
                                if(sec <= 9){sec="0"+sec}
                                zmon=new Array();
                                zmon=["January","February","March","April","May","Ju ne", "July","August","September","October","Novembe r"," December"];
                                zday=new Array();
                                zday=["Sunday","Monday","Tuesday","Wednesday","Thurs day" ,"Friday","Saturday"];
                                document.myForm2.clock.value=" Fourteen days from now will be "+zday[day]+", "+zmon[mon]+" "+date+", "+year+"";}
                                runClock();
                                //--></script>
                                Navaldesign
                                Logger Lite: Low Cost, Customizable, multifeatured Login script
                                Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
                                DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
                                Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

                                Comment

                                Working...
                                X