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 38 7161 Ro****@BeatToBe at.com wrote: 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.
The date constructor can take a number of milliseconds as an argument
to create a date object from. Perhaps this example will be of use:
<script>
var dt = new Date();
var dt2 = new Date(dt.getTime ()+15*24*60*60* 1000);
alert(dt+"\n"+d t2);
</script>
Refer to: http://msdn.microsoft.com/library/de...6jsobjdate.asp Ro****@BeatToBe at.com wrote:
[snip] document.write( months[month] +' ' + date + ', ' + year); //--> </SCRIPT> ---
<script type="text/javascript">
var today = new Date();
today.setDate(t oday.getDate()+ 15);
document.write(
['January','Febr uary','March',' April','May','J une','July',
'August','Septe mber','October' ,'November','De cember'][today.getMonth( )]+
" "+today.getDate ()+
", "+today.getFull Year()
);
</script>
if you find yourself using it a lot, create a Date.prototype
Date.prototype. addDays=functio n(days){
this.setDate(th is.getDate()+da ys)
// do stuff with the revised date object if you want to.
}
Mick
Mick Ro****@BeatToBe at.com wrote: I have a script... ----- <SCRIPT language="JavaS cript" type="text/javascript">
The language attribute is depreciated:
<script type="text/javascript">
<!--
Hiding scripts with HTML comments is unnecessary and potentially
harmful, just don't do it.
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]; }
Neither of these functions is needed, see below. 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 months = [
'January','Febr uary','March',' April','May','J une',
'July','August' ,'September','O ctober','Novemb er','December'
];
var days = new makeArray0('Sun day','Monday',' Tuesday','Wedne sday','Thursday ','Friday','Sat urday');
var days = [
'Sunday','Monda y','Tuesday','W ednesday',
'Thursday','Fri day','Saturday'
];
var today = new Date();
Relying on the client PC's clock is unreliable, there are other
strategies, read the group FAQ:
<URL:http://www.jibbering.c om/faq>
You can add 15 days directly to the date object:
var today = new Date();
today.setDate(t oday.getDate()+ 15);
var day = days[today.getDay()]; var date = today.getDate( ) + 15; var month = today.getMonth( ) + 1; var year = y2k(today.getYe ar());
Delete all the above.
document.write( months[month] +' ' + date + ', ' + year);
document.write(
months[today.getMonth( )] + ' '
+ days[today.getDay()] + ' '
+ today.getFullYe ar()
);
</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.
Sorry, but the laugh's on you. The value returned by getDate() is a
number, so adding any other number will give a normal arithmetic
addition.
<script type="text/javascript">
var months = [
'January','Febr uary','March',' April','May','J une',
'July','August' ,'September','O ctober','Novemb er','December'
];
var days = [
'Sunday','Monda y','Tuesday','W ednesday',
'Thursday','Fri day','Saturday'
];
var today = new Date();
today.setDate(t oday.getDate()+ 15);
document.write(
days[today.getDay()] + ', '
+ today.getDate() + ' '
+ months[today.getMonth( )] + ', '
+ today.getFullYe ar()
);
</script>
--
Rob
Jc wrote: Ro****@BeatToBe at.com wrote: 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.
The date constructor can take a number of milliseconds as an argument to create a date object from. Perhaps this example will be of use:
<script> var dt = new Date(); var dt2 = new Date(dt.getTime ()+15*24*60*60* 1000); alert(dt+"\n"+d t2); </script>
Refer to: http://msdn.microsoft.com/library/de...6jsobjdate.asp
Forgot about setDate, yeah, use that. :)
JRS: In article <9c************ *************** @msgid.meganews servers.co
m>, dated Fri, 17 Jun 2005 15:32:11, seen in news:comp.lang. javascript, Ro****@BeatToBe at.com posted : I have a script...
Delete it, learn javascript, read and understand the newsgroup FAQ, and
start again.
<SCRIPT language="JavaS cript" type="text/javascript">
^^^^^^^^^^^^^^^ ^^^^^^ not required<!-- 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]; }
Not needed. And if you want the first word to be indexed 0 or 1, use a
parameter rather than two routines, or supply a dummy zeroth entry.
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
Not correct in all systems; see FAQ & sig. Function getFullYear is
generally available; and, if not, can be accurately emulated.
However, since your work is unlikely to be wanted for very long, you can
safely use 2000 + number%100 with a note about its range.
var months = new makeArray('Jan uary','February ','March','Apri l','May','June' ,'July','August ','Se p tember','Octob er','November', 'December');
DO NOT let your posting agent break lines of code; do it yourself.
Posted code should be directly executable.
var months = ['January', 'February', 'March', 'April', 'May',' June',
'July', 'August', 'September', 'October', 'November', 'December']
var days = new makeArray0('Su nday','Monday', 'Tuesday','Wedn esday','Thursda y','Friday','Sa turda y ');
var days = ['Sunday', 'Monday', 'Tuesday',
'Wednesday', 'Thursday', 'Friday', 'Saturday']
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);
Don't use FFF, or anything like it, on the WWW.
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.
So you were, on the previous day, prepared to believe June 31st?
Yes, that's exactly what you asked for, and should have foreseen.
You need to increment the date object, not the day-of-month.
Ignore any response containing 864e5 or its equivalent; it will not be
reliable for all potential users. Consider
function LZ(x) { return (x<0||x>=10?"": "0") + x }
with (new Date()) {
setDate(getDate ()+15)
document.writel n(
getFullYear(), '-', LZ(getMonth()+1 ), '-', LZ(getDate()) ) }
--
© 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.
JRS: In article <42b37997$0$113 33$5a62ac22@per-qv1-newsreader-
01.iinet.net.au >, dated Sat, 18 Jun 2005 11:32:02, seen in
news:comp.lang. javascript, RobG <rg***@iinet.ne t.auau> posted : Relying on the client PC's clock is unreliable, there are other strategies, read the group FAQ:
<URL:http://www.jibbering.c om/faq>
Which section? 4.30 refers to the page server clock.
My view is that if the date/time matters to the page author's
organisation, then it can be applied to the submitted response after
receipt at the server end; but if otherwise then it's up to the end user
to have his clock set as he wishes.
<FAQENTRY> FAQ 4.17 is in error in the text; the current date is not
unique. The code rightly uses the current GMT/UTC date/time, which is
(near enough) unique (the clock may be corrected backwards [but no
concern for the end of Summer Time]). Also, an "of" should be an "or".
FAQ 4.31, "everytime" -> "every time"
--
© 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.
Dr John Stockton wrote: JRS: In article <42b37997$0$113 33$5a62ac22@per-qv1-newsreader- 01.iinet.net.au >, dated Sat, 18 Jun 2005 11:32:02, seen in news:comp.lang. javascript, RobG <rg***@iinet.ne t.auau> posted :
Relying on the client PC's clock is unreliable, there are other strategies, read the group FAQ:
<URL:http://www.jibbering.c om/faq>
Which section? 4.30 refers to the page server clock.
Section 3.2 has "Manipulati ng times, dates and the lastModified date
and time in javascript :-" followed by a link to your pages, where
there is a section "Some date troubles".
I was highlighting that using the client PC solely to determine the
date or time is not sensible. If the intention is to advise an
approximate delivery time or similar, it may be best to use dates and
times based on some accurate datum convenient to the OP, rather than
the client, then suggest what the equivalent *might* be at the client
location based on the client system date/time and tell the user that
that is how they were calculated.
--
Rob Ro****@BeatToBe at.com wrote: I need this script to advance the document.write by 15 days,
Maybe the following script might be of use for you:
var fst = "+15d";
var dte = new Date();
var plusMinus = fst.match(/[+-]\d+[smhdy]/gi);
if (plusMinus) {
var vorz, shrt, val;
var multiplier = {"S":1,"M":60," H":3600,"d":864 00};
for (var i=0; i<plusMinus.len gth; i++) {
vorz = plusMinus[i].charAt(0) == "+" ? 1 : -1;
shrt = plusMinus[i].charAt(plusMin us[i].length-1);
val = vorz*Number(plu sMinus[i].substring(1,pl usMinus[i].length-1));
if (shrt == "m")
dte.setMonth(dt e.getMonth() + val);
else if (shrt.toLowerCa se() == "y")
dte.setFullYear (dte.getFullYea r() + val);
else if (multiplier[shrt])
dte.setTime(dte .getTime() + (val*multiplier[shrt]*1000));
}
}
alert(dte);
You may now add or substract seconds, minutes, hours, days, months or
years to your Date object (dte).
Use "+5S" for fst to add 5 seconds, use "-10d" to substract 10 days, use
"-2H" to substract 2 hours etc.
S = Seconds
M = Minutes
H = Hours
d = Days
m = Months
y = Years
Daniel
RobG <rg***@iinet.ne t.auau> wrote: Hiding scripts with HTML comments is unnecessary and potentially harmful, just don't do it.
Why so? It seems to be a rather ubiquitous idiom, and in any case how
else would one hide script from user agents that can't or won't
execute it?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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
|
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...
|
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...
|
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.
| |
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...
|
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....
|
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
|
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()
{
|
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...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |