0

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!

2 Answers 2

1

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");

JavaScript Date Format

Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

Please post your code here, because JS Fiddle (semi-frequently) falls over.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.