Dates, Tomorrow and Next Day

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Smoke

    #1

    Dates, Tomorrow and Next Day

    I have a successful script for determining today's date.

    Does anyone have anything for determining tomorrow and the next day since it
    would have to look at the day of month and month of year?

    Thanks in advance.


  • Lasse Reichstein Nielsen

    #2
    Re: Dates, Tomorrow and Next Day

    "Smoke" <smoke@xatrium. com> writes:
    [color=blue]
    > I have a successful script for determining today's date.[/color]

    Like
    var today = new Date();
    ?
    [color=blue]
    > Does anyone have anything for determining tomorrow and the next day since it
    > would have to look at the day of month and month of year?[/color]

    The FAQ gives this link to information on dates:
    <URL:http://www.merlyn.demo n.co.uk/js-dates.htm>
    If it isn't there, it's not worth knowing.

    To get the day after today (or after any day), do:

    var day = new Date();
    day.setDate(day .getDate()+1);

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Smoke

      #3
      Re: Dates, Tomorrow and Next Day

      I cannot see from the info on your link or from your not below how this
      would work. I believe also you answered my question the other week, thanks
      again for that. Below is what is working. If today was the 31st of December
      2003, how would a script look that would know to automatically know that
      tomorrow would be 01012004?

      var d = new Date();

      var filename = "" + (d.getMonth() + 1) + (d.getDate()) + (d.getFullYear( ));

      var fileextension = ".gif";

      var file = filename + fileextension;

      document.write( "<img src=http://www.website.com/graphics/"+file+"
      width='358' height='233' border='0' alt='' >");

      the url below is only good for today





      "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
      news:wu9wmo62.f sf@hotpop.com.. .[color=blue]
      > "Smoke" <smoke@xatrium. com> writes:
      >[color=green]
      > > I have a successful script for determining today's date.[/color]
      >
      > Like
      > var today = new Date();
      > ?
      >[color=green]
      > > Does anyone have anything for determining tomorrow and the next day[/color][/color]
      since it[color=blue][color=green]
      > > would have to look at the day of month and month of year?[/color]
      >
      > The FAQ gives this link to information on dates:
      > <URL:http://www.merlyn.demo n.co.uk/js-dates.htm>
      > If it isn't there, it's not worth knowing.
      >
      > To get the day after today (or after any day), do:
      >
      > var day = new Date();
      > day.setDate(day .getDate()+1);
      >
      > /L
      > --
      > Lasse Reichstein Nielsen - lrn@hotpop.com
      > DHTML Death Colors:[/color]
      <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>[color=blue]
      > 'Faith without judgement merely degrades the spirit divine.'[/color]


      Comment

      • Evertjan.

        #4
        Re: Dates, Tomorrow and Next Day

        Smoke wrote on 19 nov 2003 in comp.lang.javas cript:[color=blue]
        > I cannot see from the info on your link or from your not below how
        > this would work.[/color]

        [please do not underquote on usenet]

        Try this:

        <SCRIPT>
        var myday = new Date(2003,12,31 );
        alert(myday)
        myday.setDate(m yday.getDate()+ 1);
        alert(myday)
        </SCRIPT>

        As you see a day set to 2003-12-32
        will be automaticly be stored by .setDate as 2004-01-01.


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • Michael Winter

          #5
          Re: Dates, Tomorrow and Next Day

          Evertjan. wrote on 19 Nov 2003:
          [color=blue]
          > Smoke wrote on 19 nov 2003 in comp.lang.javas cript:[color=green]
          >> I cannot see from the info on your link or from your not below how
          >> this would work.[/color]
          >
          > [please do not underquote on usenet]
          >
          > Try this:
          >
          > <SCRIPT>[/color]

          Type?
          [color=blue]
          > var myday = new Date(2003,12,31 );[/color]

          This isn't correct. Those values will produce a date of Saturday, 31
          January 2004. Month ordinals, when used with the getMonth/setMonth
          methods, their UTC counterparts, and the Date constructor, are zero
          based. The correct assignment is:

          var myday = new Date( 2003, 11, 31 );
          [color=blue]
          > alert(myday)
          > myday.setDate(m yday.getDate()+ 1);
          > alert(myday)
          > </SCRIPT>
          >
          > As you see a day set to 2003-12-32
          > will be automaticly be stored by .setDate as 2004-01-01.[/color]

          Mike

          --
          Michael Winter
          M.Winter@blueyo nder.co.uk.invalid (remove ".invalid" to reply)

          Comment

          • Dr John Stockton

            #6
            Re: Dates, Tomorrow and Next Day

            JRS: In article <Xns9438BEE3385 15eejj99@194.10 9.133.29>, seen in
            news:comp.lang. javascript, Evertjan. <exjxw.hannivoo rt@interxnl.net >
            posted at Wed, 19 Nov 2003 17:45:15 :-[color=blue]
            >Smoke wrote on 19 nov 2003 in comp.lang.javas cript:[color=green]
            >> I cannot see from the info on your link or from your not below how
            >> this would work.[/color]
            >
            >[please do not underquote on usenet][/color]
            ^^^^^^^^^^

            That word actually means "quote too little". The chief sin is in fact
            overquoting. Try "Please do not bottom-quote in News".

            [color=blue]
            >As you see a day set to 2003-12-32
            >will be automaticly be stored by .setDate as 2004-01-01.[/color]

            OP : see <URL:http://www.merlyn.demo n.co.uk/js-date1.htm#FR>, Field
            Rollover.

            --
            © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
            <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
            <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
            <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

            Comment

            • Evertjan.

              #7
              Re: Dates, Tomorrow and Next Day

              Michael Winter wrote on 19 nov 2003 in comp.lang.javas cript:[color=blue]
              > This isn't correct. Those values will produce a date of Saturday, 31
              > January 2004. Month ordinals, when used with the getMonth/setMonth
              > methods, their UTC counterparts, and the Date constructor, are zero
              > based. The correct assignment is:
              >
              > var myday = new Date( 2003, 11, 31 );[/color]

              You are right, my mistake.

              The example stil shows the right result changing the 31st
              by storing the 1st of next month.



              --
              Evertjan.
              The Netherlands.
              (Please change the x'es to dots in my emailaddress)

              Comment

              • Evertjan.

                #8
                Re: Dates, Tomorrow and Next Day

                Dr John Stockton wrote on 19 nov 2003 in comp.lang.javas cript:
                [color=blue][color=green]
                >>[please do not underquote on usenet][/color]
                > ^^^^^^^^^^
                >
                > That word actually means "quote too little". The chief sin is in fact
                > overquoting. Try "Please do not bottom-quote in News".
                >[/color]

                Right John, the result of posting alsio in Dutch NG's.
                [color=blue][color=green]
                >>As you see a day set to 2003-12-32
                >>will be automaticly be stored by .setDate as 2004-01-01.[/color][/color]

                You didn't you miss my mistake?
                new Date(2003,12,31 ); // new Date(2003,11,31 );

                --
                Evertjan.
                The Netherlands.
                (Please change the x'es to dots in my emailaddress)

                Comment

                • Dr John Stockton

                  #9
                  Re: Dates, Tomorrow and Next Day

                  JRS: In article <Xns9438E67C24B 0MWinterBlueyon der@193.38.113. 46>, seen
                  in news:comp.lang. javascript, Michael Winter <M.Winter@bluey onder.co.uk.
                  invalid> posted at Wed, 19 Nov 2003 22:39:28 :-[color=blue]
                  >[color=green]
                  >> var myday = new Date(2003,12,31 );[/color]
                  >
                  >This isn't correct. Those values will produce a date of Saturday, 31
                  >January 2004. Month ordinals, when used with the getMonth/setMonth
                  >methods, their UTC counterparts, and the Date constructor, are zero
                  >based. The correct assignment is:
                  >
                  >var myday = new Date( 2003, 11, 31 );[/color]

                  Yes and no.

                  If the date is indeed constant, and the numbers are not to be replaced
                  at a later stage by variables,
                  var myday = new Date( "2003/12/31" );
                  is better. It is the same length, the month number is unmistakable, and
                  it provides an example of ISO-8601 date fields and order (numeric YDM is
                  never used). A truly enlightened browser would also accept the proper
                  form "2003-12-31".

                  --
                  © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                  <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                  <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
                  <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

                  Comment

                  Working...