简体   繁体   中英

Return time to the Jtable

I got a jQuery jTable in my website. In the jTable there is a field test which basically displays date and time. I want to display only the time. So, I have a function like this.

 test:{
            title:'test time',
            display:function(data){
                time = data.record.test; // getting from backend
                var d = new Date(time);
                console.log(d.getHours(),':',d.getMinutes(),':',d.getSeconds());
            },

        },

When I run the code, it works fine as expected in the console ie It prints the time like this and this is what I am looking for.

8 : 42 : 29
8 : 42 : 39
8 : 43 : 32
8 : 43 : 42
8 : 47 : 48

But when I use return instead of console.log it returns only the seconds, so only the seconds are shown in my jTable like this (29, 39, 32, 42, 48). So how can I return the time with HH:mm:ss in the same format to the jTable.

Thanks

我只是用它来返回多个值

return[d.getHours(),':',d.getMinutes(),':',d.getSeconds()]

try

return d.getHours()+':'+d.getMinutes()+':'+d.getSeconds();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM