Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: format date

  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Thanked 0 Times in 0 Posts

    format date

    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.

  2. #2
    Regular Coder
    Join Date
    Mar 2006
    Thanked 132 Times in 123 Posts
    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;


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts