millsy007 Posted March 6, 2009 Share Posted March 6, 2009 I have recently changed my page so my date that is held in a textbox is in the European Format, ie DD/MM/YYYY The problem is all of my other javascript functions expect it in the 'normal' format. Is there a way I can change the format I now have it in back, so: datevariable = document.getElementById('date').value; switches back from dd/MM/yyyy to MM/dd/yyyy Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 7, 2009 Share Posted March 7, 2009 Might be an easier way, but this will work. You can use it to covnert back and forth. Whatever format you are inputting you will get the opposite out. function reverseDayMonth(dateStr) { dateArr = dateStr.split('/'); return dateArr[1]+'/'+dateArr[0]+'/'+dateArr[2]; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.