第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

來自貓鼬日期戳的 JS 日期格式

來自貓鼬日期戳的 JS 日期格式

忽然笑 2021-11-18 20:37:50
我知道類似的問題已被問過很多次,但沒有答案是我正在尋找的。我的代碼如下所示:        <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>專注于這條線:<td><%-x.createdAt%></td>在網(wǎng)上查看是這樣的:2019 年 9 月 27 日星期五 17:38:08 GMT+0200(南非標(biāo)準(zhǔn)時(shí)間)我希望它看起來像什么:2019 年 9 月 27 日使用moment.js 這可能嗎?我試過的: 在頂部:<script src="/js/moment.js"></script>然后(用于測(cè)試目的的硬編碼日期)<td><script>moment('1977-08-20 14:29:00 UTC').format('dd MMM YYYY')</script>   </td>
查看完整描述

1 回答

?
搖曳的薔薇

TA貢獻(xiàn)1793條經(jīng)驗(yàn) 獲得超6個(gè)贊

我實(shí)際上對(duì) JS 很陌生,我花了幾分鐘才弄明白,但實(shí)際上非常簡(jiǎn)單..


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

改為


<td class="formattedDate"><%-x.createdAt%></td>

并在添加以下內(nèi)容之前的底部:


<script src="/js/jquery-3.3.1.js"></script>


<script>

$(document).ready(function () {

    var x = document.getElementsByClassName('formattedDate');

    for (i = 0; i < x.length; i++) {

        x[i].innerHTML = moment(x[i].innerHTML).format('DD MMM YYYY');

    }

});

</script> 

希望這可以幫助


查看完整回答
反對(duì) 回復(fù) 2021-11-18
  • 1 回答
  • 0 關(guān)注
  • 148 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)