Can Java Script allow me to calculate a future date?

Discussion in 'Javascript' started by rohayre@gmail.com, Aug 13, 2006.

  1. Guest

    Im a long time java developer and actually have never done anything
    with java scripting. I'd like to write a short simple script for
    calculating a date in the future based on today's date and a letter.
    Can I use javascripting to create a webpage to allow a user to enter a
    letter and then click a button to find a future calendar date? I'm just
    not sure how much user interaction scripting allows. Does java
    scripting allow buttons, textfields and the ability to put enough
    smarts in to calculate a future date?
     
    , Aug 13, 2006
    #1
    1. Advertising

  2. напиÑа:
    > Im a long time java developer and actually have never done anything
    > with java scripting. I'd like to write a short simple script for
    > calculating a date in the future based on today's date and a letter.

    You can make this easily. See the reference for JavaScript Date object.
    http://www.w3schools.com/jsref/jsref_obj_date.asp
    This is smal example how to add one day to current date:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title></title>
    <script type="text/javascript">
    var today=new Date();
    today.setDate(today.getDate()+1);
    document.write("Tomorrow is:"+ today.toLocaleString());
    </script>
    </head>
    <body>
    </body>
    </html>

    > Can I use javascripting to create a webpage to allow a user to enter a
    > letter and then click a button to find a future calendar date? I'm just
    > not sure how much user interaction scripting allows. Does java
    > scripting allow buttons, textfields and the ability to put enough
    > smarts in to calculate a future date?

    Yes JavaScript is very usefull for this tasks. Tell me your idea and I
    will help you with a
    pleasure.
    Best Regardss
     
    Georgi Naumov, Aug 13, 2006
    #2
    1. Advertising

  3. JRS: In article <>
    , dated Sun, 13 Aug 2006 01:00:36 remote, seen in
    news:comp.lang.javascript, posted :
    >Im a long time java developer and actually have never done anything
    >with java scripting.


    There is no space in "Javascript".

    > I'd like to write a short simple script for
    >calculating a date in the future based on today's date and a letter.
    >Can I use javascripting to create a webpage to allow a user to enter a
    >letter and then click a button to find a future calendar date?


    Yes, and if you had read the newsgroup FAQ ... See sig.

    > I'm just
    >not sure how much user interaction scripting allows. Does java
    >scripting allow buttons, textfields and the ability to put enough
    >smarts in to calculate a future date?


    See for example <URL:http://www.merlyn.demon.co.uk/js-clndr.htm>.

    Javascript goes only up to AD 275760-09-13 with the built-in capability;
    but can do up to about AD 3E12 if you code your own.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr John Stockton, Aug 13, 2006
    #3
  4. JRS: In article <>, dated
    Sun, 13 Aug 2006 12:55:45 remote, seen in news:comp.lang.javascript, Jim
    Davis <> posted :
    >
    >As far as adding to the current date (getting the future date) JavaScript's
    >Date object is very rich. There are "set" and "get" methods for all data
    >parts and several abstractions.



    Actually, there is only one data part, an IEEE Double of milliseconds
    from 1970.0 GMT. There are "get" methods for most derivable components
    of conventional forms of the UTC/local date/time (but not Week Number,
    although ISO 8601 defines it). For most of those, but not all, there is
    a "set" method.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr John Stockton, Aug 13, 2006
    #4
  5. JRS: In article <>, dated
    Mon, 14 Aug 2006 01:20:53 remote, seen in news:comp.lang.javascript, Jim
    Davis <> posted :
    >"Dr John Stockton" <> wrote in message
    >news:p...
    >> JRS: In article <>, dated
    >> Sun, 13 Aug 2006 12:55:45 remote, seen in news:comp.lang.javascript, Jim
    >> Davis <> posted :
    >>>
    >>>As far as adding to the current date (getting the future date)
    >>>JavaScript's
    >>>Date object is very rich. There are "set" and "get" methods for all data
    >>>parts and several abstractions.

    >>
    >>
    >> Actually, there is only one data part, an IEEE Double of milliseconds
    >> from 1970.0 GMT. There are "get" methods for most derivable components
    >> of conventional forms of the UTC/local date/time (but not Week Number,
    >> although ISO 8601 defines it). For most of those, but not all, there is
    >> a "set" method.

    >
    >Sorry - typo. I meant "date part".
    >
    >Although (since you got me thinking) "data part" is, I think, applicable -
    >not physically as in the memory storage of the implementation but rather (as
    >you imply) as information derivable from that implementation. It's
    >applicable since I was talking about the interface to the Date object rather
    >than the implementation.


    > ...


    There is a test, ISTM : The Date Object is required to behave as if it
    stores just an IEEE Double of milliseconds from 1970.0 GMT, limit 10^8
    days-worth; but it is neither required to store only that, not to store
    exactly that.

    Using only UTC functions, set a date from year, month, day and then read
    out year, month, day in that order. We know that converting YMD to
    milliseconds and milliseconds to YMD are tasks of similar complexity.
    If setting YMD and reading Y take similar times but then reading M & D
    is much faster, then there must be some sort of cache for M & D and
    presumably Y; if each of the four take a similar time, then probably
    only milliseconds are stored. That could be browser-dependent.


    I've now put the code for function setDay in my js-date8.htm; also a
    proposed method for setting the Week. Corresponding setUTC... functions
    are then obvious. But function setTimezoneOffset is probably
    impossible.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr John Stockton, Aug 14, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James P.
    Replies:
    7
    Views:
    12,753
    phamtasmic
    Jul 13, 2004
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,380
    Michael Borgwardt
    May 30, 2004
  3. Jeff
    Replies:
    2
    Views:
    990
    clintonG
    Sep 19, 2006
  4. Laery
    Replies:
    11
    Views:
    1,002
    Laery
    Feb 25, 2005
  5. Golan
    Replies:
    3
    Views:
    378
Loading...

Share This Page