Time conversion problem

Convert and print the given time in 24-hour format. code is below. can u pls explain this:

#include
using namespace std;

int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
string s;
string h;
int hr;
cin>>s;
hr = ((s[0]-‘0’)*10)+(s[1]-‘0’);
if(s[8]==‘P’&&s[9]==‘M’&& hr ==12) cout<<to_string(hr);
else if(s[8]==‘P’&&s[9]==‘M’) cout<<to_string(hr+12);
else if(s[8]==‘A’&&s[9]==‘M’&&hr==12) cout<<“00”;

else cout<< s[0]<<s[1];


for(int i =2;i<8;i++)
    cout<<s[i];
cout<<endl;
return 0;

}

@neharika.srivastav
I don’t understand your query. Your code seems correct. What’s the issue here ? If there is some particular line or a part of code you cannot understand , let me know the exact lines so I can help you out.