In message <11**********************@f16g2000cwb.googlegroups .com>, Sat,
21 Oct 2006 10:10:52, trz <te****@gmail.comwrites
>Hi Im new to this I was looking for javascript that will display the
following:
If the current day is less than the 15th that it would display the
current Month and the 30th. i.e.
This offer is good until November 15th or This offer is good until
November 30th .
am I clear?
Inadequately. Firstly, February exists. Secondly, it might be the
31st.
The following should, on the 1st..14th, give the 15th, otherwise the
last, of the current month.
with (D = new Date())
getDate()<15 ? setDate(15) : setMonth(getMonth()+1, 0)
But your specification is inadequate to indicate what you really want,
and suggests that you have not given enough thought to the problem
itself before seeking a solution.
For January to April inclusive, post a critical table of the ISO-8601
date/times and the desired results, such as
2004-01-01.0
2004-01-15
2004-01-15.0
2004-01-31
....
If this is a commercial application, you may need to deal with the
user's local date being different to the date at the Company. Consider
a New Yorker visiting New Zealand and wanting to deal with Hawaii.
If this is coursework, admit it.
It's a good idea to read the newsgroup and its FAQ. See below.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.