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
Hi I try to do this within my function:
var tmp = document.getElementById('date').value;
var tmp = ddmmyyyy.split('/');
var date = tmp[1]+'/'+tmp[0]+'/'+tmp[2];
But it doesnt work ?
ddmmyyyy to mmddyyyy in Javascript
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: ddmmyyyy to mmddyyyy in Javascript
Surely you'll want:millsy007 wrote: Hi I try to do this within my function:
var tmp = document.getElementById('date').value;
var tmp = ddmmyyyy.split('/');
var date = tmp[1]+'/'+tmp[0]+'/'+tmp[2];
But it doesnt work ?
Code: Select all
var tmp = document.getElementById('date').value;
var tmp = tmp.split('/');
var date = tmp[1]+'/'+tmp[0]+'/'+tmp[2];