php - change date format on json format -


i want change date format in json when bind result .

my script

$.ajax({       type: "post",       async: false,       url: "<?php echo site_url(); ?>admin/get_mail_contents",       data: datastring,       cache: false,       success: function (result) {           alert(result);           var result = $.parsejson(result);           console.log(result.from);                                               $('#content').html('');           $("#content").append('<div class="mail-toolbar clearfix"> </div><div class="divider"></div><div class="pad5a clearfix mrg10b"> <i class="glyph-icon icon-clock-o mrg5r"></i> ' + result['0']['start_time'] + ' , ' + result['0']['start_date'] + '</div></div> </div>');       } }); 

my actual out put 15:37:00 , 2017-07-25 , want print 15:37 , 25-07-2017 in view how change in json .

try this

var d = new date(result['0']['start_date'] +' '+ result['0']['start_time']);  console.log(d.gethours() + ':' + d.getminutes());  console.log((d.getdate()) + '-' + (d.getmonth() + 1) + '-' +  d.getfullyear()); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -