0

My web method is sending a date string to JavaScript e.g. "05/06/2014 09:00:00" in "dd/MM/yyyy hh:mm" format. But When I try to create a Date object in javascript it inverts the day and month. How Can I have a date object in JavaScript with "dd/MM/yyyy hh:mm" format.

2

1 Answer 1

0

You can use regular expression to make the changes.

var dateString= ... ; // "MM/dd/yyyy hh:mm"
dateString = dateString.replace( /(\d+)\/(\d+)\/(\d+)/i , "$2/$1/$3");
// dateString = "dd/MM/yyyy hh:mm"
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.