You need to sign in to do that
Don't have an account?
Shuhbam Sinha
How to conver Milisecods to Days Hours, Minutes and Seconds in LWC
Hello Everyone ,
I need to convert MS to Dasy:hh:mm:ss in lwc. I tried below code it is givng me days in decimal which I dnot want. Can anyone please help me on the same.
I need to convert MS to Dasy:hh:mm:ss in lwc. I tried below code it is givng me days in decimal which I dnot want. Can anyone please help me on the same.
msToTime(s) { var ms = s % 1000; s = (s - ms) / 1000; var secs = s % 60; s = (s - secs) / 60; var mins = s % 60; s= (s - mins) / 60; var hrs = s % 60; var hrs = (s - mins) / 60; var days = (s-hrs) / 24; var timer = ''; if(days && days>0){ timer = days +' days '; } if(hrs && hrs>0){ timer = timer + hrs +' hr '; } if(mins && mins>0){ timer = timer + mins +' min '; } if(secs && secs>0){ timer = timer + secs +' sec '; } return timer; } }
To convert milliseconds to days, hours, minutes, and seconds in LWC, you can go through these articles and also try with below provided code .
References ->
If the above inforamtion helps , please mark this as Best Answer.
Thank you.
If you find my answer helpful, please mark it as the best answer. Thanks