473,765 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Advance Date +15 Days

I have a script...
-----
<SCRIPT language="JavaS cript" type="text/javascript">
<!--
function makeArray() {
for (i = 0; i<makeArray.arg uments.length; i++)
this[i + 1] = makeArray.argum ents[i];
}

function makeArray0() {
for (i = 0; i<makeArray0.ar guments.length; i++)
this[i] = makeArray0.argu ments[i];
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var months = new
makeArray('Janu ary','February' ,'March','April ','May','June', 'July','August' ,'September','O ctober','Novemb er','December') ;
var days = new
makeArray0('Sun day','Monday',' Tuesday','Wedne sday','Thursday ','Friday','Sat urday');

var today = new Date();
var day = days[today.getDay()];
var date = today.getDate( ) + 15;
var month = today.getMonth( ) + 1;
var year = y2k(today.getYe ar());

document.write( months[month] +' ' + date + ', ' + year);
//-->
</SCRIPT>
---

I need this script to advance the document.write by 15 days, as you can see
I tried adding "+ 15"
after the Var Date = today.getDate( ) that works fin until it started
showing 32 days in June
today. LOL.

Can anyone please assist me? Ro****@BeatToBe at.com

Thank you,
Robert
Jul 23 '05
38 7163
Michael Winter <m.******@bluey onder.co.invali d> wrote:
All a user agent needs to do once it reads a SCRIPT opening tag is
ignore everything until it encounters </


Pedantry: Actually, "</" followed by a name start character (a-zA-Z),
i.e. ETAGO delmiter-in-context, or NET ("/") if the start tag was NET-
enabling.

--
David Håsäther
Jul 23 '05 #21
JRS: In article <d9************ *@news.t-online.com>, dated Tue, 21 Jun
2005 11:26:55, seen in news:comp.lang. javascript, Daniel Kirsch
<Iw************ *****@gmx.de> posted :
Dr John Stockton wrote:
Not good.

If new Date('2005/10/21'); is used, then, since there are 31 days in
October, the answer should be November 5th. However, if executed in the
EU or in much of North America, the result will be in November 4th.

Did you not see that I warned the OP "Ignore any response containing
864e5 or its equivalent;"?


Thanks. Added
if (shrt == "d")
dte.setDate(dte .getDate() + val);

Anything else "not good"?


Well, the RegExp test should perhaps be case-sensitive; and you need to
think about what +3H should do to Sun 2005/10/30 00:00:00. As you have
it, it gives 2 o'clock; but with setHours it would give 3 o'clock.

If the change cannot be done, the date should possibly be set to NaN.

vorz = plusMinus[i].charAt(0) == "+" ? 1 : -1;
or vorz = plusMinus[i].charAt(0) + "1" // ??

Actually, you don't need vorz; RegExp match with
X = fst.match(/([+-]\d+)([SMHdmy])/)
then +X[1] can be used as val and X[2] as the selector.

Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
01:00:30.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #22
Dr John Stockton wrote:
Well, the RegExp test should perhaps be case-sensitive; and you need to
think about what +3H should do to Sun 2005/10/30 00:00:00. As you have
it, it gives 2 o'clock; but with setHours it would give 3 o'clock.
Of course. But that's pretty theoretical :-)
Actually, you don't need vorz; RegExp match with
X = fst.match(/([+-]\d+)([SMHdmy])/)
then +X[1] can be used as val and X[2] as the selector.
Thanks.

Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
01:00:30.


Works for me. It gives me "2:00:30".

Daniel
Jul 23 '05 #23
JRS: In article <d9************ *@news.t-online.com>, dated Wed, 22 Jun
2005 15:19:02, seen in news:comp.lang. javascript, Daniel Kirsch
<Iw************ *****@gmx.de> posted :
Dr John Stockton wrote:

Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
01:00:30.


Works for me. It gives me "2:00:30".


Yes; but you're presumably in Germany. Try it in German time, a clock
hour later.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #24
> Michael Winter <m.win...@bluey onder.co.invali *d> wrote:
Script 'hiding' has been around for so long that many don't know why it

began in the first place, or that it stopped being necessary years ago.

I wonder if you can say the same about multi-line comment tags around
CDATA open and close tags placed in a script in a few years. In xhtml
you are required to surround the script with open and close CDATA tags
to avoid possible conflict with xml, if any is included in the xhtml
page. The problem is that most current browsers do not understand the
xml CDATA tags and completely kill the script, if you use them. The W3C
xhtml 1.0 and 1.1 validators will validate such a page perfectly, if it
has no errors. However if you leave the CDATA tags off, the validators
make a terrible fuss. However if you surround the CDATA open and close
tags with the multi-line javascript tags, everyone is happy. The page
works, and the validators and a proper xhtml delivery see right through
the javascripts to view the XML CDATA tags. I believe I first learned
about this at the Opera forum nearly 2 years ago from a member of the
Opera design team. Of course the easy way out is to use an external
javascript file, which avoids all of this fuss. However, many still
insist on including the script on the main page.

PS The Google beta groups site has been acting up at times for the last
day or two. It sometimes does not put the quoted message in the text
box, and you have to highlight and copy it to the response text box.
Until this problem resolves, some posts made from Google are going to
look strange. Major US ISPs including MSN and AOL have dropped Usenet
groups. I and many others are not interested in newsreaders just to
make a few posts in Usenet. Nearly everyone I know reads NGs online.
Most plans here allow unlimited, or very large, time on line, and many
even with dialup leave the computer on for many hours at a time.

Jul 23 '05 #25
On 23/06/2005 09:40, cw******@yahoo. com wrote:

[snip]
The problem is that most current browsers do not understand the
xml CDATA tags and completely kill the script, if you use them.


The rather blatantly obvious solution is to not serve XHTML(-like)
documents to user agents that don't explicitly state[1] they support it.

There is no benefit in serving XHTML as text/html, and XML tools can
transform their output to HTML so there is no excuse here, either.

[snip]

Mike
[1] IE says it supports anything in its request headers, so you have to
ignore things like that when negotiating XHTML.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #26
JRS: In article <11************ *********@g47g2 000cwa.googlegr oups.com>,
dated Thu, 23 Jun 2005 01:40:20, seen in news:comp.lang. javascript,
cw******@yahoo. com <cw******@yahoo .com> posted :

PS The Google beta groups site has been acting up at times for the last
day or two. It sometimes does not put the quoted message in the text
box, and you have to highlight and copy it to the response text box.
Until this problem resolves, some posts made from Google are going to
look strange. Major US ISPs including MSN and AOL have dropped Usenet
groups. I and many others are not interested in newsreaders just to
make a few posts in Usenet. Nearly everyone I know reads NGs online.
Most plans here allow unlimited, or very large, time on line, and many
even with dialup leave the computer on for many hours at a time.


If providers in your country provide only shoddy services, it is you who
should suffer, not us; you merit no sympathy. Pay for a good service,
and demand it.
If you find that, when you start a News reply, Google does not provide
the previous article in quoted form, note what Keith Thompson wrote in
comp.lang.c, message ID <ln************ @nuthaus.mib.or g> :-
If you want to post a followup via groups.google.c om, don't use
the "Reply" link at the bottom of the article. Click on "show
options" at the top of the article, then click on the "Reply" at
the bottom of the article headers.

Since that is what the experts in this newsgroup prefer to read, it will
be to your advantage to comply.

--
© John Stockton, Surrey, UK. ??*@merlyn.demo n.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Jul 23 '05 #27
Dr John Stockton wrote:
JRS: In article <d9************ *@news.t-online.com>, dated Wed, 22 Jun
2005 15:19:02, seen in news:comp.lang. javascript, Daniel Kirsch
<Iw************ *****@gmx.de> posted :
Dr John Stockton wrote:
Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
01:00:30.

Works for me. It gives me "2:00:30".


Yes; but you're presumably in Germany. Try it in German time,
a clock hour later.


I am in Germany where next change from Daylight Saving Time to
"normal" time is scheduled on Sunday, 2005-10-30, 03:00:00.000
local (DS)time, using the German time locale.

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050610
Firefox/1.0.4 (Debian package 1.0.4-3) Mnenhy/0.7.2.0

shows for `new Date(2005, 9, 30, 1, 59)'
"Sun Oct 30 2005 01:59:00 GMT+0200 (CEST)"
which is correct;

for `new Date(2005, 9, 30, 2, 59)'
"Sun Oct 30 2005 02:59:00 GMT+0100 (CET)"
which is incorrect

and so for `new Date(new Date(2005, 9, 30, 2, 59).getTime() + 3600000)'
"Sun Oct 30 2005 03:59:00 GMT+0100 (CET)"
which is correct according to "common sense".

Apparently, the JavaScript 1.5 engine of my UA is not up to date or not
properly using the locale. The second expression should have given

"Sun Oct 30 2005 02:59:00 GMT+0200 (CEST)"

as change from local DST to local "normal" time is scheduled only a
minute later (ref. <http://zeitumstellung. de/>). Or am I missing
something?
PointedEars
Jul 23 '05 #28
cw******@yahoo. com wrote:
Michael Winter <m.win...@bluey onder.co.invali *d> wrote:
Script 'hiding' has been around for so long that many don't know why it began in the first place, or that it stopped being necessary years ago.

^^
This quote is borken, although Google Groups may error-correct that for
display. The technical flaws of Google Groups posts are many, especially
in the new version; please avoid using it, use a proper newsreader
application instead.
I wonder if you can say the same about multi-line comment tags around
CDATA open and close tags placed in a script in a few years. In xhtml
you are required to surround the script with open and close CDATA tags
to avoid possible conflict with xml, if any is included in the xhtml
page.


No, you are not. As it is but a PCDATA issue, you may instead escape markup
characters within the PCDATA content that script or style content is in
XHTML, e.g. `&lt;' for `<' (JS: less-than operator; CSS: child selector),
&gt; for `>' (JS: greater-than operator) and so on.

It is only that the UA(s) tested with or targeted, most notably Internet
Explorer, are not capable of processing XHTML and so do not support CDATA
_content declarations_ which is why commenting out those declarations is
necessary; not using the unsupported markup language in the first place
(but sticking to widely, if not always, supported HTML 4.01, Strict DTD
if possible) or including/linking to a script or style file would have
avoided the original problem.
PointedEars
Jul 23 '05 #29
JRS: In article <47************ ****@PointedEar s.de>, dated Sun, 3 Jul
2005 19:40:18, seen in news:comp.lang. javascript, Thomas 'PointedEars'
Lahn <Po*********@we b.de> posted :
Dr John Stockton wrote: (about ten days ago)
JRS: In article <d9************ *@news.t-online.com>, dated Wed, 22 Jun
2005 15:19:02, seen in news:comp.lang. javascript, Daniel Kirsch
<Iw************ *****@gmx.de> posted :
Dr John Stockton wrote:
Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
01:00:30.
Works for me. It gives me "2:00:30".


Yes; but you're presumably in Germany. Try it in German time,
a clock hour later.


I am in Germany


Apparently, the JavaScript 1.5 engine of my UA is not up to date or not
properly using the locale. The second expression should have given

"Sun Oct 30 2005 02:59:00 GMT+0200 (CEST)"

as change from local DST to local "normal" time is scheduled only a
minute later (ref. <http://zeitumstellung. de/>). Or am I missing
something?


Probably.

Rather than looking at such as
new Date(2005, 9, 30, 1, 59)
it would be simpler to look at
new Date(2005, 9, 30, 1, 59).getTimezone Offset()
or
new Date("2005/10/30 00:59:00 GMT").getTimezo neOffset()

One can get javascript to determine when the clock change is thought to
occur : <URL:http://www.merlyn.demo n.co.uk/js-clndr.htm#Ctrls > shows it.

Unfortunately, operating systems are often written and configured in a
country which has a considerable reputation for ignorance both about
time and about the rest of the world; so your OS may have incorrect
data.
You wrote :
for `new Date(2005, 9, 30, 2, 59)'
"Sun Oct 30 2005 02:59:00 GMT+0100 (CET)"
which is incorrect
Is it? Local time 02:59 occurs twice, once at the end of Summer and
once at the start of Winter, and ISTM that you see the latter. After
the clock has been put back, it continues going forwards.

Indeed, AIUI, the first version of Windows 95 (cf. ibid. 13,14/19) sets
the clock back whenever it thinks that the clock has reached 2 a.m. on
the day in question, not just on the first occasion.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5219
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much appreciated. TIA
16
41637
by: sandy | last post by:
Hi, Using Java script I am trying to create code where when you place in the start date it automatically calculates 6 months for the experations date. For example when I place 01/01/04 as the issue date the experation date should automaically generate as 06/01/04. I would appreciate it if anyone could help me. Thank you Sandy
4
5390
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm working on it but not making much progress. Is there any free code available anywhere? I know it...
6
39817
by: bryan.seaton | last post by:
I have a delete statement that is not doing what I want it to do: Delete from LOG_TABLE where (DATE(LOG_TS)) < (DATE(CURRENT_DATE)- 21 DAYS); It is supposed to delete all records that are 21 days or older than the current system date. Instead it is deleting all new rows. LOG_TS is a timestamp but that should not matter since DATE returns just the date portion of a date or timestamp...right? I'm not a SQL guru but I can't see...
1
6134
by: Wayne | last post by:
Hi all I'm trying to calculate the number of days (or workdays) between 2 given dates that do not include weekend days or public holidays (public holidays are user defined from a dbase, have a start date & an end date & may span a weekend) If a start date (workday) & an end date (workday) are on the same day then the number of workdays will equal zero Some eg's.
29
9128
by: james | last post by:
I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old database file that has the date(s) stored in it as number of days. An example is: 36,525 represents 01/01/1900. The starting point date is considered to be : 00/00/0000. I have looked thru Help and used Google and have not really found an answer. I know that Leap Years need to be accounted for too. Any...
4
15758
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow which calculated the difference in years and days between two dates, and takes leap years into account? I'm calculating the difference in the usual way, i.e....
7
3354
by: No bother | last post by:
I have a table which has, among other fields, a date field. I want to get a count of records where certain criteria are met for, say, three days in a row. For example: NumWidgets Date 1 1/1/2000 10 1/2/2000 20 1/3/2000 10 1/4/2000 15 1/5/2000
7
4166
by: kr151080 | last post by:
Ok so I am messing around with a program and have no idea how to go about doing this but here is the code for the class date.... public class Date { private int dMonth; private int dDay; private in dYear; public Date() {
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.