テーブルの並べ替えとフィルタリングに次のスクリプトを使用しています。
http://javascripttoolbox.com/lib/table/
ソースコード:
http://javascripttoolbox.com/libsource.php/table/source/table.js
日付の形式は dd-MM-yyyy です。
スクリプトには、日付を並べ替えるための 3 つの組み込みの RegEx 関数があります。
sort.date.formats = [
// YY[YY]-MM-DD
{
re: /(\d{2,4})-(\d{1,2})-(\d{1,2})/,
f: function (x) {
return (new Date(sort.date.fixYear(x[1]), +x[2], +x[3])).getTime();
}
}
// MM/DD/YY[YY] or MM-DD-YY[YY]
,
{
re: /(\d{1,2})[\/-](\d{1,2})[\/-](\d{2,4})/,
f: function (x) {
return (new Date(sort.date.fixYear(x[3]), +x[1], +x[2])).getTime();
}
}
// Any catch-all format that new Date() can handle. This is not reliable except for long formats, for example: 31 Jan 2000 01:23:45 GMT
,
{
re: /(.*\d{4}.*\d+:\d+\d+.*)/,
f: function (x) {
var d = new Date(x[1]);
if (d) {
return d.getTime();
}
}
}];
問題は、dd-MM-yyyy 形式の日付の正規表現はどのようになるかということです。
ここにjsFiddleを作成しました:
あなたのソリューションが期限列で機能するかどうか教えてください!