var dt = new Date(); var dtstring = dt.getFullYear() + '-' + pad2(dt.getMonth()+1) + '-' + pad2(dt.getDate()) + ' ' + pad2(dt.getHours()) + ':' + pad2(dt.getMinutes()) + ':' + pad2(dt.getSeconds());
That will then put the current date and time into a database format e.g. "2009-04-24 07:00:00" which is the date and time this post is scheduled for publishing.
Note that getMonth() returns a number between 0 and 11 so 1 needs to be added to it. Although the day of the month function is labelled getDate() it does actually return the day of the month as a number between 1 and 31.