Turn clock value into total count of miliseconds

Hi everyone, i would like to ask if someone can turn this clock value into mili seconds? This is a string. It should be dynamic for all other string. I am currently working on a time messuring line for my music game.

The string given here (red arrow) is the total duration of the game. It is stored in a text file that the game will use to get the song informations.

The other value (green arrow) is the current time of the song, It is formated like this minute: second: milisecond

Well. Now i dont know how to make python turn the string value there into the same format like the current time T.T

If my questions are not understandable, feel free to ask me.


In case some body suggest me to change the time value in the external file, i would answer it will then give errors.


To convert to milliseconds just do this


millis = (60000 * minutes + 1000 * seconds) / 1000

Thanks Twister GE, can you please tell me how can i split the AA:BB into minute and second values? thanks

def getMilliSeconds(stringchain):    
    stringchain = stringchain.split(":")
    seconds = 60 * int(stringchain[0]) + int(stringchain[1])
    milliSeconds = seconds * 1000
    print(milliSeconds)
    return milliSeconds


getMilliSeconds("01:02")

(works only for XX:XX or X:X (minutes/seconds) formated strings). Maybe time module has a function to do this kind of operations…

I think using the builtin split method should work. https://docs.python.org/2/library/stdtypes.html#str.split

wow thanks guys, it seems functioning well here. weeee

i actually need only the XX:XX format. it is the value i save in an external text file. During the game. the song length is calculated into XX:XX:XX with the module time ( pohjan coded this for me before). I need these 2 values to get the percentage value between them. So i can apply to the song length indicating object, to make it scale from 0.0 to 1.0