JRS: In article <cf**************************@posting.google.com >,
dated Mon, 19 Jul 2004 19:13:56, seen in news:comp.lang.javascript,
Robert Scheer <rb******@my-deja.com> 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.