How can I Convert HH:MM:SS into minute using javascript ?
            Asked
            
        
        
            Active
            
        
            Viewed 2.3k times
        
    14
            
            
        - 
                    1what you mean with minute? post input-output example please – Jordi Castilla Oct 01 '15 at 10:52
 - 
                    2split the string on `:` parseInt and do appropriate multiplications/divisions on each of the 3 parts in the result – Jaromanda X Oct 01 '15 at 10:52
 - 
                    could you post you code? – demonplus Oct 01 '15 at 10:52
 
2 Answers
34
            
            
        Use split and multiply per 60 ignoring seconds.
Taking this answer as base:
var hms = '02:04:33';   // your input string
var a = hms.split(':'); // split it at the colons
// Hours are worth 60 minutes.
var minutes = (+a[0]) * 60 + (+a[1]);
console.log(minutes);
Use split and multiply per 60 using seconds as decimal (thus is not full exact)
var hms = '02:04:33';   // your input string
var a = hms.split(':'); // split it at the colons
// Hours are worth 60 minutes.
var minutes = (+a[0]) * 60 + (+a[1]);
console.log(minutes + "," + ((+a[2]) / 60));
        Community
        
- 1
 - 1
 
        Jordi Castilla
        
- 26,609
 - 8
 - 70
 - 109