Compare user date with system date

Discussion in 'Javascript' started by Robert Scheer, Jul 20, 2004.

  1. Hi.

    My user types a date on a textbox using the DD/MM/YYYY format. I need
    to verify that this date is not older than 2 months ago. Have seen
    some functions to test dates but not with the above format.

    Thanks,
    Robert Scheer
    Robert Scheer, Jul 20, 2004
    #1
    1. Advertising

  2. JRS: In article <>,
    dated Mon, 19 Jul 2004 19:13:56, seen in news:comp.lang.javascript,
    Robert Scheer <> posted :

    >My user types a date on a textbox using the DD/MM/YYYY format. I need
    >to verify that this date is not older than 2 months ago. Have seen
    >some functions to test dates but not with the above format.


    Did you not find the newsgroup FAQ sufficiently helpful?

    See below.



    YYYY/MM/DD would be better; if you are sure that the form will be either
    DD/MM/YYYY or YYYY/MM/DD, then the following will convert the former to
    the latter if needed - I think :-

    S = S.replace(/^(\d\d)\/(\d\d)\/(\d\d\d\d)$/, "$3/$2/$1")

    You will need to think about "two months ago" for Aug 31 and for April
    29; if you have authority, it would be easier to use 60 days.

    Do not let the result be adversely affected by Summer Time.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://jibbering.com/faq/> JL / RC : FAQ for 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, Jul 20, 2004
    #2
    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,443
    phamtasmic
    Jul 13, 2004
  2. CZ
    Replies:
    1
    Views:
    686
    Jack Li
    Sep 23, 2005
  3. Michael Haas

    compare date field to current date

    Michael Haas, Feb 15, 2004, in forum: ASP General
    Replies:
    4
    Views:
    268
    Mike Haas
    Feb 15, 2004
  4. Scott Knapp

    Compare Input Date to Server Date

    Scott Knapp, Oct 2, 2003, in forum: Javascript
    Replies:
    2
    Views:
    167
    Dr John Stockton
    Oct 2, 2003
  5. joeyej
    Replies:
    7
    Views:
    126
    Randy Webb
    Apr 6, 2006
Loading...

Share This Page