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

# Thread: dd/mm/yy --> mm/dd/yy

1. ## dd/mm/yy --> mm/dd/yy

dd/mm/yy --> mm/dd/yy
Any known script for this?

Or better, any DateDiff script that works with the dd/mm/yy format?

thanks

• Code:
```function dateDiff(date1, date2)
{
// EXPECTS 2 DATES IN dd/mm/yy or dd/mm/yyyy FORMAT
var date1Array = date1.split('/');
var date2Array = date2.split('/');

// IF LENGTH OF DATE IS 2 CHARS CONVERT TO 4 CHARS
if (date1Array[2].length == 2)
{
if (date1Array[2] > 70)
date1Array[2] = '19'+date1Array[2];
else
date1Array[2] = '20'+date1Array[2];
}

if (date2Array[2].length == 2)
{
if (date2Array[2] > 70)
date2Array[2] = '19'+date2Array[2];
else
date2Array[2] = '20'+date2Array[2];
}

// CREATE DATE OBJECTS
var date1Obj = new Date(date1Array[2], date1Array[1]-1, date1Array[0]);
var date2Obj = new Date(date2Array[2], date2Array[1]-1, date2Array[0]);

var oneDay=1000*60*60*24;

// CONVERT DATE OBJECTS TO TIMESTAMPS
var date1Stamp = date1Obj.getTime();
var date2Stamp = date2Obj.getTime();

// CALCULATE NUMBER OF DAYS BETWEEN DATES
if (date1Stamp > date2Stamp)
alert(Math.ceil((date1Stamp - date2Stamp) / oneDay));
else
alert(Math.ceil((date2Stamp - date1Stamp) / oneDay));
}```
Hope this helps

• That's great! Thanks alot!

•

#### Posting Permissions

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