Reputation: 6543
I hope you can help me with some JavaScript because I'm a bit lost..
I'm trying to achieve in the easiest way the next format of string for Date object.
var now = new Date();
//how to convert to a pattern like this example: "30/1/2012 20:00:00" ?
Thanks in advance!
Upvotes: 0
Views: 527
Reputation: 7600
using the format
function in the below link, you can do something like:
var now = new Date();
now.format("dd/mm/yyyy hh:mm:ss");
Upvotes: 1
Reputation: 17032
The easy way: http://jsfiddle.net/tftd/UtVnU/
var date = new Date();
//how to convert to a pattern like this example: "30/1/2012 20:00:00" ?
var time = date.getDay()+"/"+date.getMonth()+"/"+date.getYear()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
alert(time) /* Outputs 6/2/112 22:16:15 */
You can get everything from the variable date
.
Upvotes: 1