JSON 日期格式 - 仅显示时间

JSON Date format - display time only

我有一个使用 Bootstrap tables 的应用程序,其中一个字段是时间。当我从数据库中获取数据时,它以 JSON 格式编码,该字段的数据类似于 2016-11-07T13:40:29.000Z,据我所知这是标准的 JSON 格式.

我想把它分开,让我的 table 中的一栏显示日期,另一栏显示时间,这是理想情况。但如果我能让时间列只显示时间,我会很高兴。

我读到这与向列 header 添加 dataFormatter 有关,但我似乎无法让它工作,因为我的 javascript returns NaN.

这是我在研究问题时找到的代码。我是 Javascript 的新手,所以这里可能有一些错误,我希望得到一些帮助。

<table id="table"  data-url ="http://maccdx161012:4567/api/v1/sat" data-toggle="table">
    <thead>
        <tr>

           <th data-field="initials">Initials</th>
            <th data-field="sector">Sector</th>
            <th data-field="cjs">CJS</th>
            <th data-field="satin" data-formatter="timeFormatter">In</th> 
            <th data-field="satout">Out</th> 
            <th data-field="duration">Duration</th> 
            <th data-field="position">Position</th>
            <th data-field="ot">OT</th>             
        </tr>
    </thead>
 </table>
<script>
    function timeFormatter(value) {
        var date = new Date(value*1000);
        var hours = date.getHours();
        var minutes = "0" + date.getMinutes();

        return hours + ':' + minutes.substr(-2);
    }
</script>
<script>
    function timeFormatter(value) {
        var date = new Date(value);
        var hours = date.getHours();
        var minutes = leadZero(date.getMinutes());

        return hours + ':' + minutes;
    }
    function dateFormatter(value) {
        var date = new Date(value);
        var years = date.getFullYear();
        var months = leadZero(date.getMonth() + 1);
        var days = leadZero(date.getDate());

        return years + '-' + months + '-' + days;
    }
    function leadZero(n) { return n>9 ? n : "0" + n; }
</script>

它将 return 计时为您当地的时区。如果您不想要此功能 - 使用 Keith 的解决方案。