Created
February 28, 2011 08:10
-
-
Save siculars/847062 to your computer and use it in GitHub Desktop.
test various strings to see how well they Date.parse() ... or don't. open in various browsers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | |
<title>Demo</title> | |
</head> | |
<body> | |
<script language="javascript"> | |
testdates = [ | |
'' | |
,'2011' | |
,'JAN' | |
,'JANUARY' | |
,'January' | |
,'January 2011' | |
,'Jan 2011' | |
,'Jan 01' | |
,'Jan 1' | |
,'jan 1 2011' | |
,'jan 01 2011' | |
,'jan 01 2011 08:00' | |
,'jan 01 11' | |
,'2011 jan 1' | |
,'2011 january 1' | |
,'2011 jan 01' | |
,'2011 january 01' | |
,'2011 january 01 08:00' | |
,'20110101' | |
,'20110101T0800' | |
,'20110101T0800Z' | |
,'20110101T08:00Z' | |
,'2011 01 01' | |
,'2011-01-01' | |
,'2011/01/01' | |
,'01JAN2011' | |
,'01JAN11' | |
,'01/JAN/2011' | |
,'01/JAN/11' | |
,'01-JAN-2011' | |
,'01-JAN-11' | |
,'01 01 11' | |
,'01 01 2011' | |
,'01 01 2011 08:00' | |
,'01 01 2011,08:00' | |
,'01 JAN, 11' | |
,'01 JAN, 11 08:00' | |
,'01 JAN, 11,08:00' | |
,'01 JAN, 11T08:00' | |
,'01 JAN, 11T08:00Z' | |
,'01 JAN, 11T08:00:00Z' | |
,'01 JAN, 2011' | |
,'01 JAN, 2011 08:00' | |
,'01 JAN, 2011,08:00' | |
,'01 JAN, 2011T08:00' | |
,'01 JAN, 2011T08:00Z' | |
,'01 JAN, 2011T08:00:00Z' | |
,'2011-01-01 08:00' | |
,'2011-01-01 08:00:00' | |
,'2011-01-01T08:00' | |
,'2011-01/01T08:00Z' | |
,'2011-01/01 08:00Z' | |
,'2011-01/01T08:00:00Z' | |
,'2011-01/01 08:00:00Z' | |
,'2011-01-01T08:00:00.000Z' | |
,'2011-01-01 08:00:00.000Z' | |
,'01-01-2011 08:00' | |
,'01-01-2011 08:00:00' | |
,'01-01-2011T08:00' | |
,'01-01-2011T08:00Z' | |
,'01-01-2011 08:00Z' | |
,'01-01-2011T08:00:00Z' | |
,'01-01-2011 08:00:00Z' | |
,'01-01-2011T08:00:00.000Z' | |
,'01-01-2011 08:00:00.000Z' | |
,'2011/01/01 08:00' | |
,'2011/01/01 08:00:00' | |
,'2011/01/01T08:00' | |
,'2011/01/01T08:00Z' | |
,'2011/01/01 08:00Z' | |
,'2011/01/01T08:00:00Z' | |
,'2011/01/01 08:00:00Z' | |
,'2011/01/01T08:00:00.000Z' | |
,'2011/01/01 08:00:00.000Z' | |
,'01/01/2011 08:00' | |
,'01/01/2011 08:00:00' | |
,'01/01/2011T08:00' | |
,'01/01/2011T08:00Z' | |
,'01/01/2011 08:00Z' | |
,'01/01/2011T08:00:00Z' | |
,'01/01/2011 08:00:00Z' | |
,'01/01/2011T08:00:00.000Z' | |
,'01/01/2011 08:00:00.000Z' | |
] | |
document.write('<table><tr><th>date</th><th>parsed</th></tr>') | |
for(var i=0, len=testdates.length;i<len;i++){ | |
document.write( '<tr><td>' + testdates[i] | |
+ '</td><td>' + Date.parse( testdates[i] ) | |
+ '</td></tr>') | |
} | |
document.write('</table>') | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment