Convert duration to seconds in js

mcswan
Kilo Contributor

Hi,

How do you convert   duration   to seconds in js.

Exporting duration to excel give the value in seconds. eg. 600

In Js,   duration using obj.getDisplayvalue() gives me "10 min"

is there a obj.getseconds()?   so it comes out in seconds - consistent with the excel export?

1 ACCEPTED SOLUTION

Try below code:



1)myobj.getGlideObject().getNumericValue();


View solution in original post

7 REPLIES 7

Kannan Nadar
Tera Guru

Hi Michael,



You would have to create a new custom string field and store the display value of your duration field in it and then export it to excel.


Apart from this I am really not aware of any OOB way to achieve it.



Thanks,


Kannan


Gowrisankar Sat
Tera Guru

var duration = obj.getNumericValue();


var durationSeconds = (duration/1000);



This should give the duration in seconds.


if (x === "u_glide_duration_1")


{



var duration = myobj.getNumericValue();



var durationSeconds = (duration/1000);




jsonstring += '"duration":"'   + durationSeconds/*.getDisplayValue()*/   + '",';


jsonstring += '"duration":"'   + myobj.getDisplayValue()   + '",';


}



jsonstring output:



"duration":"NaN","duration":"1 Minute"



I don't know why it's getting NaN. It returns 1 minute with the getdisplayvalue()



duration is nan.


Try below code:



1)myobj.getGlideObject().getNumericValue();