I think you need to turn you dates into a yyyy-mm-dd
string that will sort properly like this:
da = new Date(document.lastModified) // Create a Date Object set to the last modifed date
dy = da.getFullYear() // Get full year (as opposed to last two digits only)
dm = da.getMonth() + 1 // Get month and correct it (getMonth() returns 0 to 11)
dd = da.getDate() // Get date within month
if ( dy < 1970 ) dy = dy + 100; // We still have to fix the millennium bug
ys = new String(dy) // Convert year, month and date to strings
ms = new String(dm)
ds = new String(dd)
if ( ms.length == 1 ) ms = "0" + ms; // Add leading zeros to month and date if required
if ( ds.length == 1 ) ds = "0" + ds;
ys = ys + "-" + ms + "-" + ds // Combine year, month and date in ISO format
document.write ( "Last Updated " + ys ) // Display the result
Thanks to
http://home.clara.net/shotover/datetest.htm