StackOverflow StackOverflow - 1 year ago 87
Javascript Question

How to convert digits in format "hhmmss" to time format hh:mm:ss using javascript?

I have string like

and i want to change it to time format like
(like date format of type string) using javascript or jquery. How can i do this work?

Answer Source

You can easily split string to two-digit numbers using regex in String.prototype.match() that return values in array. Then use Array.prototype.join() to joins items of array into string.

var str = "080000";
str = str.match(/\d{2}/g).join(":");

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download