How to subtract timestamps?
How to subtract timestamps?
Hi,
I am looking for solution, how to subtract two timestamps. Before I used DataTables plugin, I have specified this in my sql query, but now I do not know if this is possible to do.
In my db I have two columns with time stamps. TimeA and TimeB I need display in table difference between this two times e.g. 20 minutes.
I tried to use render option
"data":null,
render:function (data, type, row) {
return ''+(row.cs_TimeB+row.TimeA)+'';
but it shows following text: 2016-12-04 15:49:032016-12-04 15:49:03
Is there any other way to achieve my goal? e.g. in sql query?
Thanks in advance for your help!
Answers
I modified above code to this:
but it gives me NaN. It looks like my values in TimeA, TimeB columns are string.
Is there any way to do this, e.g. get this value from JSON?
Moment is an outstanding Javascript library for manipulating date time information.
Allan