javascript - How do you convert dates in JSONBootstrap-Table to DDMMYYYY - Stack Overflow

I want to format 2016-09-14T13:46:39+0000 to DDMMYYYY. The data is ing from a JSON fileurl into a bo

I want to format 2016-09-14T13:46:39+0000 to DD/MM/YYYY. The data is ing from a JSON file/url into a bootstrap-table. Is there a way to format this using bootstrap-table or javascript?

See jsfiddle

Thanks,

<table data-toggle="table" 
   data-url=""
   data-row-style="rowStyle">
<thead>
<tr>
    <th data-field="createdAt">Created At</th>
</tr>
</thead>

I want to format 2016-09-14T13:46:39+0000 to DD/MM/YYYY. The data is ing from a JSON file/url into a bootstrap-table. Is there a way to format this using bootstrap-table or javascript?

See jsfiddle

Thanks,

<table data-toggle="table" 
   data-url="https://api.myjson./bins/44564"
   data-row-style="rowStyle">
<thead>
<tr>
    <th data-field="createdAt">Created At</th>
</tr>
</thead>

Share Improve this question asked Nov 14, 2016 at 14:36 NinjaShawarmaNinjaShawarma 691 gold badge1 silver badge10 bronze badges 9
  • It might just make sense to search the web for "javascript date format" or something similar, no? – Dave Newton Commented Nov 14, 2016 at 14:38
  • @DaveNewton I have tried, but it got me confused. :( – NinjaShawarma Commented Nov 14, 2016 at 14:39
  • here is the google link google./… – Kevin Kloet Commented Nov 14, 2016 at 14:40
  • But there are running examples on the web and on Stack Overflow. I'd remend at least trying something before asking someone to do it for you, but maybe that's just me. In general SO is for specific problems as opposed to asking people to do all the work. – Dave Newton Commented Nov 14, 2016 at 14:40
  • 1 @Igor I've looked into the API but I couldn't find something useful. Thanks! I will dig deep. – NinjaShawarma Commented Nov 14, 2016 at 14:44
 |  Show 4 more ments

1 Answer 1

Reset to default 9

Check this will resolve your issue.. Am using moment js to format data.. ..

function dateFormat(value, row, index) {
   return moment(value).format('DD/MM/YYYY');
}
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://momentjs./downloads/moment.min.js"></script>
<script src="https://rawgit./wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<link href="https://rawgit./wenzhixin/bootstrap-table/master/src/bootstrap-table.css" rel="stylesheet"/>

<table data-toggle="table" 
       data-url="https://api.myjson./bins/44564"
       data-row-style="rowStyle">
    <thead>
    <tr>
        <th data-field="createdAt" data-formatter="dateFormat">Created At</th>
    </tr>
    </thead>
</table>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743784447a4506397.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>