/    Sign up×
Community /Pin to ProfileBookmark

datetime stamp

Hi all

Im trying to parse a datetime stamp “mysql format” ‘YYYY-MM-DD HH:MM:SS’
into (‘mysqldato’).value …but getting an syntax error:

hope someone got a clue ?

function dato(){

var d=new Date()
var weekday=d.getDay();
var hours=d.getHours();
var minutes=d.getMinutes();
var month=d.getMonth();
var seconds=d.getSeconds();
var monthday=d.getDate();
var year=d.getYear();

document.getElementById(‘mysqldato’).value = parse(year+”-“+monthday+”-“+weekday+” “+hours+”:”+minutes+”:”+seconds);
}

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoNov 01.2005 — First off, you should probably use parseInt not just parse. Second, often times with dates if you don't create the variables in the same order that you try to display them then they mess up. Try rearranging them like below. Thirdly, make sure to end all lines with a semi-colon, and lastly, you put in monthday where you needed month.
<i>
</i>function dato(){

var d=new Date()
var year=d.getYear();
var month=d.getMonth();
var weekday=d.getDay();
var hours=d.getHours();
var minutes=d.getMinutes();
var seconds=d.getSeconds();

document.getElementById('mysqldato').value = parseInt(year+"-"+month+"-"+weekday+" "+hours+":"+minutes+":"+seconds);
}


And make sure that you have the name 'mysqldato' correct. You have to create the id for the object, not just the name.
Copy linkTweet thisAlerts:
@me2authorNov 01.2005 — thanks....
×

Success!

Help @me2 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.21,
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,
)...