/usr/bin/time –format output elapsed time in milliseconds

One possibility is to use the date command: ts=$(date +%s%N) ; my_command ; tt=$((($(date +%s%N) – $ts)/1000000)) ; echo “Time taken: $tt milliseconds” %N should return nanoseconds, and 1 millisecond is 1000000 nanosecond, hence by division would return the time taken to execute my_command in milliseconds. NOTE that the %N is not supported on all … Read more

Javascript: convert 24-hour time-of-day string to 12-hour time with AM/PM and no timezone

Nothing built in, my solution would be as follows : function tConvert (time) { // Check correct time format and split into components time = time.toString ().match (/^([01]\d|2[0-3])(:)([0-5]\d)(:[0-5]\d)?$/) || [time]; if (time.length > 1) { // If time format correct time = time.slice (1); // Remove full string match value time[5] = +time[0] < 12 … Read more

How to convert milliseconds to “hh:mm:ss” format?

You were really close: String.format(“%02d:%02d:%02d”, TimeUnit.MILLISECONDS.toHours(millis), TimeUnit.MILLISECONDS.toMinutes(millis) – TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)), // The change is in this line TimeUnit.MILLISECONDS.toSeconds(millis) – TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))); You were converting hours to millisseconds using minutes instead of hours. BTW, I like your use of the TimeUnit API 🙂 Here’s some test code: public static void main(String[] args) throws ParseException { long millis = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)