/    Sign up×
Community /Pin to ProfileBookmark

Date script not returning the correct values

Can anyone help with this one… am new to Javascript.. when I run the following script and get the following output…

In the head section:

<code>
function makeDate()
{
now = new Date();
return now.getYear() + ‘/’ + (now.getMonth()+1) + now.getDate();
}
</code>

In the body section:
<code>
<BODY onLoad=”document.test.dateField.value = makeDate()”>

I put the output in a text field in a form with:

<form name=”test” action=”mypage.php” method=”post”>

and

<input type=”text” name=”dateField” size=”16″ maxlength=”16″ value=””>

</code>

With the following result…

106/48

Any help would be greatly appreciated….

Dave

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 09.2006 — Change this:

return now.getYear() + '/' + (now.getMonth()+1) + now.getDate();

to this:

return now.get[COLOR=Red]Full[/COLOR]Year() + '/' + (now.getMonth()+1) + [COLOR=Red][B]'/' +[/B][/COLOR] now.getDate();
Copy linkTweet thisAlerts:
@PittLimeyauthorApr 09.2006 — Thanks that worked great...

Appreciate your help.

Dave
Copy linkTweet thisAlerts:
@phpnoviceApr 09.2006 — You're welcome.

Cheers.
×

Success!

Help @PittLimey 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 5.22,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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