Edit in JSFiddle

function duration()
{
    var audio = document.getElementById("audio-element");
    if(audio.readyState > 0) 
    {
        var minutes = parseInt(audio.duration / 60, 10);
        var seconds = parseInt(audio.duration % 60);
        
        alert(minutes+":"+seconds);
    }
}
<audio id="audio-element" controls>
  <source src="http://labs.qnimate.com/files/ogg.ogg" type="audio/ogg">
  <source src="http://labs.qnimate.com/files/mp3.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>
<br>
<button onclick="duration();">Get Duration</button>