FooTable 插件日期时间问题

FooTable plugin datetime issue

我使用 FooTable jQuery 插件创建了一个动态 table。 http://jsbin.com/wasawa/edit

这里我使用MySQL时间戳,使用PHPdate('Y-m-d H:i:s')格式。例如- 2016-01-19 01:22:13,但使用 FooTable 我没有得到实际的日期格式。

如有任何帮助,我们将不胜感激。

更新了列对象,如下所示:

{ "name": "createdat", "title": "Created On", "formatter": function(value){ return moment(value).format('MMM Do YY'); } }

我必须更新格式化程序功能。

现在它按预期工作正常。

感谢您的支持。

如果这可以帮助遇到同样问题的其他人。我能够使用以下内容从站点获取示例。您必须包含 moment.js 才能正常工作。 https://momentjs.com/

此代码不会 运行 在 SO 的代码 运行 中,因为 footable 需要本地存储。

它可以根据需要显示来自外部源的 unix 时间。我在这个例子中使用 MMM Do YY。

jQuery(function($) {
  $('#showcase-example-22').footable({
    "useParentWidth": true,
    columns: [

      {
        "name": "id",
        "title": "ID",
        "breakpoints": "xs sm",
        "type": "number",
        "style": {
          "width": 80,
          "maxWidth": 80
        }
      },
      {
        "name": "firstName",
        "title": "First Name"
      },
      {
        "name": "lastName",
        "title": "Last Name"
      },
      {
        "name": "something",
        "title": "Never seen but always around",
        "visible": false,
        "filterable": false
      },
      {
        "name": "jobTitle",
        "title": "Job Title",
        "breakpoints": "xs sm",
        "style": {
          "maxWidth": 200,
          "overflow": "hidden",
          "textOverflow": "ellipsis",
          "wordBreak": "keep-all",
          "whiteSpace": "nowrap"
        }
      },
      {
        "name": "started",
        "title": "Started On",
        "type": "numeric",
        "breakpoints": "xs sm md"
      },
      {
        "name": "dob",
        "title": "Date of Birth",
        "formatter": function(value) {
          var datetime = JSON.parse(value)
          return moment(datetime).format("MMM Do YY")

        }
      },
      {
        "name": "status",
        "title": "Status"
      }
    ],
    rows: [{
        "id": 1,
        "firstName": "Annemarie",
        "lastName": "Bruening",
        "something": 1381105566987,
        "jobTitle": "Cloak Room Attendant",
        "started": 1367700388909,
        "dob": 122365714987,
        "status": "Suspended"
      },
      {
        "id": 2,
        "firstName": "Nelly",
        "lastName": "Lusher",
        "something": 1267237540208,
        "jobTitle": "Broadcast Maintenance Engineer",
        "started": 1382739570973,
        "dob": 183768652128,
        "status": "Disabled"
      },
      {
        "id": 3,
        "firstName": "Lorraine",
        "lastName": "Kyger",
        "something": 1263216405811,
        "jobTitle": "Geophysicist",
        "started": 1265199486212,
        "dob": 414197000409,
        "status": "Active"
      },
      {
        "id": 4,
        "firstName": "Maire",
        "lastName": "Vanatta",
        "something": 1317652005631,
        "jobTitle": "Gaming Cage Cashier",
        "started": 1359190254082,
        "dob": 381574699574,
        "status": "Disabled"
      },
      {
        "id": 5,
        "firstName": "Whiney",
        "lastName": "Keasler",
        "something": 1297738568550,
        "jobTitle": "High School Librarian",
        "started": 1377538533615,
        "dob": -11216050657,
        "status": "Active"
      },
      {
        "id": 6,
        "firstName": "Nikia",
        "lastName": "Badgett",
        "something": 1283192889859,
        "jobTitle": "Clown",
        "started": 1348067291754,
        "dob": -236655382175,
        "status": "Active"
      }
    ]
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/3.1.4/footable.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/3.1.4/footable.bootstrap.css" rel="stylesheet" />



<table id="showcase-example-1" class="table" data-paging="true" data-filtering="true" data-sorting="true" data-editing="true" data-state="true"></table>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/3.1.4/footable.js"></script>

enter code here