View Full Version : format date

06-11-2008, 02:44 AM
hye.. i want to ask about a format date, i have 1 form which is the date that i using is in format d/m/y, but then when i fill up the form, in database the date it will get 0000/00/00, this is because in database the format date is Y/m/d. So how can i get the format date in d/m/y. Because i want format date in d/m/y.:confused:

06-11-2008, 03:56 AM
If you validate the input from your form on the server, convert it there.
or use a dummy input (with no name attribute) and convert it to a hidden field (with a name).
Convert it by validating it before you submit the form.

dummydate.onchange= function(e){
e= window.event || e;
e= e.target || e.srcElement;
var who= document.getElementsByName('hiddendate');
var D= e.value.split(/\D+/);
var A= [D[2]*1,D[1]-1,D[0]*1];
D= new Date(A[0],A[1],A[2]);
if(D.getFullYear()== A[0] && D.getMonth()+1== A[1] && D.getDate()== A[2]){
who.value= A.join('/');
return true;
throw 'Bad Date- '+e.value;
return false;