Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q605 How can I convert a mm/dd/yy date to dd/mm/yy and vice versa?

You are here: irt.org | FAQ | JavaScript | Date | Q605 [ previous next ]

Try:

<script language="JavaScript"><!--
var mmddyy = "12/31/99";

alert(mmddyy)

var mm = mmddyy.substring(0,2);
var dd = mmddyy.substring(3,5);
var yy = mmddyy.substring(6,8);

var ddmmyy = dd + '/' + mm + '/' + yy;

alert(ddmmyy);

// and back again...

var dd = ddmmyy.substring(0,2);
var mm = ddmmyy.substring(3,5);
var yy = ddmmyy.substring(6,8);

mmddyy = mm + '/' + dd + '/' + yy;

alert(mmddyy);
//--></script>

Feedback on 'Q605 How can I convert a mm/dd/yy date to dd/mm/yy and vice versa?'

©2018 Martin Webb