| | |
Date d-m-yy to dd-mm-yyyy
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2008
Posts: 10
Reputation:
Solved Threads: 0
Thanks in advance...
My question is.. I have one text box there user types the date as follows (d-m-yy)
5-4-09 or 15-3-94
how can i convert them into exact (dd-mm-yyyy)
05-04-2009 or 15-03-1994
is there any 'javascript' code to convert the given date into my desired formt...
please help me...
My question is.. I have one text box there user types the date as follows (d-m-yy)
5-4-09 or 15-3-94
how can i convert them into exact (dd-mm-yyyy)
05-04-2009 or 15-03-1994
is there any 'javascript' code to convert the given date into my desired formt...
please help me...
Last edited by mohanvamsi_18; Aug 19th, 2009 at 7:42 am. Reason: forget to put javascript
Hi,
try this one:
try this one:
javascript Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>www.daniweb.com</title> <script type="text/javascript"> <!-- var d = document; var validate = function( field ) { var today = new Date(); var field = ( typeof( field ) === "object" ) ? field : d.getElementById( field ); if ( field && field.value.length ) { var hold = []; var stamp = [ ( today.getMonth() + 1 ), today.getDate(), today.getFullYear() ]; var date = field.value.split("-"); for ( var i = 0; i < date.length; i++ ) { var num = Number( date[ i ] ); hold[ i ] = num; hold[ i ] = (( hold[ i ] > stamp[ i ] || !hold[ i ] ) ? stamp[ i ] : hold[ i ] ); hold[ i ] = (( hold[ i ] < 10 ) ? "0" : "" ) + hold[ i ]; } (( hold[ 2 ] && String( hold[ 2 ] ).length < 4 ) ? hold[ 2 ] = stamp[ 2 ] : void( 0 )); field.value = hold.join("-"); } }; // --> </script> </head> <body> <div> <form action="#" id="testform"> <div>Date Format: <em>mm-dd-yyyy</em><br> <input type="text" id="datefield" name="datefield" size="10" maxlength="10" value="" onchange="validate( this );"> </div> </form> </div> </body> </html>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
![]() |
Similar Threads
- Want Date Format in dd/mm/yyyy in ASP.Net With C#. (C#)
- Converting date to dd/mm/yyyy format on retrieving from database (JSP)
- Inserting date in format DD-MM-YYYY in MySQL (MySQL)
- Problem while inserting into oracle date values frm vb (Visual Basic 4 / 5 / 6)
- Date format in MS Office 2000 (Visual Basic 4 / 5 / 6)
- Parsing a date into MM/DD/YYYY HH:MM:SS format (Python)
- Actual Date to Day of the Week Application (Java)
- Logic to Convert Days From 1800 to a Date (Month, Day, Year) (C++)
- Simple Time/Date Program (C)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: checkbox in html
- Next Thread: Another Checkbox question!
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser captchaformproblem cart close codes column css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 iframe index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps masterpage media menu microsoft mimic mp4 onerror onmouseoutdivproblem onmouseover paypal pdf php player position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select software sql starrating synchronous toggle unicode validation variables w3c webservice website window windowofwords xml





