/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] .setMonth and .getMonth are returning odd stings of numbers

Doing an assignment for school. I need to use javascript to get the date, write it in HTML, then increase the date and then write it again. Here’s what I have so far:

[code=php]var today = new Date();
var n = today.toTimeString();
document.write(“<p>” + n + “</p>”);
var x = today.setMonth(today.getMonth() + 1);
document.write(“<p>” + x + “</p>”);[/code]

The first document.write works great. The second one however, puts out a strange string of numbers. (1399583497190)

I’m not sure what I’m doing wrong. Some help, please?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rtretheweyApr 08.2014 — Try:
<i>
</i>var today = new Date();
document.write("&lt;p&gt;" + today + "&lt;/p&gt;");
today.setMonth(today.getMonth() + 1);
document.write("&lt;p&gt;" + today + "&lt;/p&gt;"); <br/>
Copy linkTweet thisAlerts:
@mrjaneauthorApr 08.2014 — Not quite what I was looking for, but that was my fault for how I worded my problem. I did however, use this as it condensed part of what I was doing and allowed me to see how to do the rest a little easier. I've not managed to fix the issue. Thanks so much!
×

Success!

Help @mrjane 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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