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 Link to comment https://forums.phpfreaks.com/topic/148242-switching-date-format/ 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]; } Link to comment https://forums.phpfreaks.com/topic/148242-switching-date-format/#findComment-778751 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.