最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

猫鼬日期戳中的JS日期格式

运维笔记admin11浏览0评论

猫鼬日期戳中的JS日期格式

猫鼬日期戳中的JS日期格式

我知道类似的问题已经问过很多次了,但我一直在寻找答案。.

我的代码如下:

        <table id="dtBasicExample" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
            <thead>
                <tr>
                <th class="th-sm">Date Requested
                </th>
                <th class="th-sm">Client
                </th>
                <th class="th-sm">Waybill
                </th>
                <th class="th-sm">From
                </th>
                <th class="th-sm">To
                </th>
                <th class="th-sm">Service
                </th>
                <th class="th-sm">Supplier
                </th>
                <th class="th-sm">kg
                </th>
                <th class="th-sm">Supplier
                </th>
                <th class="th-sm">VAT
                </th>
                <th class="th-sm">Total
                </th>
                <th class="th-sm">Client
                </th>
                <th class="th-sm">VAT
                </th>
                <th class="th-sm">Total
                </th>
                <th class="th-sm">Profit
                </th>
                <th class="th-sm">Status
                </th>
                <th class="th-sm">Modify
                </th>
                </tr>
            </thead>
            <tbody>
                <% for (let x of collections) {%>
                <tr style="<%= x.collectionStatusId.status == 'Requested' ? 'background-color: pink; color: black' : '' %>">
                    <td><%-x.createdAt%></td>
                    <td><%-x.clientpanyName%></td>
                    <td><%-x.waybill%></td>
                    <td><%-x.senderpany%></td>
                    <td><%-x.receiverpany%></td>
                    <td><%-x.serviceId? x.serviceId.serviceCode : ''%></td>
                    <td><%-x.supplier? x.supplier.name : ''%></td>
                    <td><%-x.chargeableWeight%></td>
                    <td><%-x.supplierRate%></td>
                    <td><%-x.supplierVat%></td>
                    <td><%-x.supplierRate + x.supplierVat%></td>
                    <td><%-x.myRate%></td>
                    <td><%-x.myVat%></td>
                    <td><%-x.myRate + x.myVat%></td>
                    <td><%-(x.myRate - x.supplierRate)%></td>
                    <td><%-x.collectionStatusId.status%></td>
                    <td><a href="/admin/<%- x.collectionStatusId.status == 'Requested' ? 'accept' : 'edit' %>/<%- x.waybill %>"><%- x.collectionStatusId.status == 'Requested' ? 'Accept' : 'Update' %></a></td>
                </tr>
                <% } %>

            </tbody>
            <tfoot>
                <tr>
                <th class="th-sm">Date Requested
                </th>
                <th class="th-sm">Client
                </th>
                <th class="th-sm">Waybill
                </th>
                <th class="th-sm">From
                </th>
                <th class="th-sm">To
                </th>
                <th class="th-sm">Service
                </th>
                <th class="th-sm">Supplier
                </th>
                <th class="th-sm">kg
                </th>
                <th class="th-sm">Supplier
                </th>
                <th class="th-sm">VAT
                </th>
                <th class="th-sm">Total
                </th>
                <th class="th-sm">Client
                </th>
                <th class="th-sm">VAT
                </th>
                <th class="th-sm">Total
                </th>
                <th class="th-sm">Profit
                </th>
                <th class="th-sm">Status
                </th>
                <th class="th-sm">Modify
                </th>
                </tr>
            </tfoot>
        </table>

关注此行:

<td><%-x.createdAt%></td>

在网络上查看,看起来像这样:

2019年9月27日星期五17:38:08 GMT + 0200(南非标准时间)

我希望它看起来像什么:

2019年9月27日

可以使用moment.js吗?

我尝试过的事情:在顶部:

<script src="/js/moment.js"></script>

然后是(出于测试目的的硬编码日期)

<td><script>moment('1977-08-20 14:29:00 UTC').format('dd MMM YYYY')</script>   </td>
回答如下:

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论