In JavaScript Language ,
I have an array … maybe it look like this
var all_date = new Array( "11/12/2009", "31/12/2010", "29/12/2011", "17/09/2011" );
Is it possible to implement a way to “guess” this date format based on the information in the array and perhaps suggest to user which date format is most likely? Such as … DD/MM/YYYY
Well of course, if the data happens to conveniently contain day values greater than 12 and have four-digit years (as the data you’ve quoted does), you’re not guessing, you can be certain you’ve got the right format.
But if it happens that all of the day values in the data are 12 or lower, it’s impossible to be certain whether the data is in U.S. MM/DD/YYYY format or the more common DD/MM/YYYY.
So no, you can’t reliably infer the format in the general case. The source of the data should provide the format information (in documentation, etc.), and ideally use a less ambiguous format such as YYYY/MM/DD.