/    Sign up×
Community /Pin to ProfileBookmark

Need JavaScript for AutomaticDate

I am working with FrontPage and need to include an automatic date which is always 3 days from the current date. I have tried to figure out on my own, but have not had any luck.? Here is what I am using for current date; again need it to be 3 days out.
Any assistance would be appreciated ?

<script language=”javascript” type=”text/javascript”>
<!–
var now = new Date();
var days = new Array(
‘Sunday’,’Monday’,’Tuesday’,
‘Wednesday’,’Thursday’,’Friday’,’Saturday’);
var months = new Array(
‘January’,’February’,’March’,’April’,’May’,
‘June’,’July’,’August’,’September’,’October’,
‘November’,’December’);
var date = ((now.getDate()<10) ? “0” : “”)+ now.getDate();
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;}
today = days[now.getDay()] + “, ” +
months[now.getMonth()] + ” ” +
date + “, ” +
(fourdigits(now.getYear()));
document.write(today);
//–>
</script></font></td>

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@astupidnameJun 03.2009 — Something like this what you're after?

[CODE]<script language="javascript" type="text/javascript">

var now = new Date();

var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];

function pad(v) {
return (v < 10) ? '0' + v : v;
}

today = days[now.getDay()] + ", " + months[now.getMonth()] + " " + pad(now.getDate()) + ", " + now.getFullYear();

document.write(today);
document.write('<br>');
now.setTime(now.getTime() + (86400000*3)); //(86400000 milliseconds in a day * number of days to add)
threeDaysFromToday = days[now.getDay()] + ", " + months[now.getMonth()] + " " + pad(now.getDate()) + ", " + now.getFullYear();
document.write(threeDaysFromToday);

</script>[/CODE]
Copy linkTweet thisAlerts:
@nfrance5authorJun 04.2009 — This is what I needed!! Thanks for your assistance
Copy linkTweet thisAlerts:
@rnd_meJun 04.2009 — why all the hard-coded English names and custom code?


[CODE]
var d1=new Date;
d1.setDate(d1.getDate()+3);
document.write(d1.toLocaleDateString());
[/CODE]


produces the exact same output , (for me), and works for speakers of all languages, with far less code to boot!
Copy linkTweet thisAlerts:
@astupidnameJun 04.2009 — why all the hard-coded English names and custom code?


[CODE]
var d1=new Date;
d1.setDate(d1.getDate()+3);
document.write(d1.toLocaleDateString());
[/CODE]


produces the exact same output , (for me), and works for speakers of all languages, with far less code to boot![/QUOTE]


Excellent catch!

toLocaleDateString.... sometimes I just forget or overlook these things :eek:
×

Success!

Help @nfrance5 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...