Liquid UI - Documentation - 9.03 Convert time from milliseconds to days/hours/minutes/seconds.

9.03 Convert time from milliseconds to days/hours/minutes/seconds.


Prerequisites

User Interface

//Create the file SAPLSMTR_NAVIGATION.E0100.sjs inside your scripts folder for customizing the SAP Easy Access screen
//Now, add the Liquid UI script to the above file, and save it.

Customization

  1. Remove the image container from the SAP Easy Access screen with the del() function.
     
    // Deletes the image container on the SAP screen
    del("X[IMAGE_CONTAINER]");
    
     
    Removes image container from SAP screen
     
  2. Add input fields labeled Enter time in milliseconds and Milliseconds converted to for value entry and display.
     
    // Creates an input field to enter the time in milliseconds
    inputfield([1,0], "Enter time in milliseconds", [1,28], {"size":10, "name":"z_milliseconds"});
    // Creates an input field to display the value
    inputfield([2,0], "Milliseconds converted to ", [2,28], {"size":10, "name":"z_converted_ms", "readonly":true});
    
     
    Input field to value and view the converted value in human-readable format
     
  3. Add a push button labeled Convert milliseconds to execute the convertmilliseconds process on click.
     
    // Creates a push button to execute the process
    pushbutton([4,7],"@01@Convert milliseconds", "?", {"process":convertMilliseconds});
    
     
    pushbutton to execute convertmilliseconds process on click
     
  4. Add timeConversion function to convert milliseconds to seconds/minutes/hours/days based on input.
     
    // Function to convert milliseconds to Days/Hours/Minutes/Seconds depending on the milliseconds value
    function timeConversion(millisec) {
        var seconds = (millisec / 1000).toFixed(2);
        var minutes = (millisec / (1000 * 60)).toFixed(2);
        var hours = (millisec / (1000 * 60 * 60)).toFixed(2);
        var days = (millisec / (1000 * 60 * 60 * 24)).toFixed(2);
    
        if (seconds < 60) {
            return seconds + " Sec";
        } else if (minutes < 60) {
            return minutes + " Min";
        } else if (hours < 24) {
            return hours + " Hrs";
        } else {
            return days + " Days"
        }
    }   
    
     function convertMilliseconds(){
        var res = timeConversion(z_milliseconds);
        set('V[z_converted_ms]','&V[res]');
        return;
    }
    
 

SAP Process

Milliseconds to seconds conversion: Values under 60,000 milliseconds display in seconds.

  1. Enter a millisecond value in the Enter time in milliseconds field, then click Convert milliseconds to view the converted seconds.
     
    converts milliseconds value to seconds
     

Converting Milliseconds to Minutes:
If the user's input is between 60,000 and 3,600,000 milliseconds, the system will display the value in minutes.

 
converts milliseconds value to minutes
 

Converting Milliseconds to Hours:
For values between 3,600,000 and 86,400,000 milliseconds (1 to 24 hours), the result displays in hours.

 
converts milliseconds value to hours
 

Converting Milliseconds to Days:
If the input value surpasses 86,400,000 milliseconds, it will be presented in days.

 
Converts milliseconds to days if value exceeds 86,400,000
 

Can't find the answers you're looking for?