From 545a85fe96f7f87eee4d519418a82c4129c30552 Mon Sep 17 00:00:00 2001 From: Shubham Bhati <112773220+Shubh2-0@users.noreply.github.com> Date: Sat, 28 Jan 2023 07:40:47 +0530 Subject: [PATCH] Create Time_Conversion --- Time_Conversion | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Time_Conversion diff --git a/Time_Conversion b/Time_Conversion new file mode 100644 index 0000000..853e38c --- /dev/null +++ b/Time_Conversion @@ -0,0 +1,41 @@ + +let s="05:05:45PM"; + + +timeconversation(s) + +function timeconversation(s){ +let ampm=s.charAt(8); +let mithours=""; +if(ampm==="A"){ + if(s.substring(0,2)=="12"){ + mithours="00"; + }else{ + mithours=s.substring(0,2); + } +}else{ + if(s.substring(0,2)=="12"){ + mithours=s.substring(0,2); + }else{ + mithours=parseInt(s.substring(0,2),10)+12 + } +} +let n= mithours+s.substring(2,8) +console.log(n) +} + +let count=-1 +for(let el of s){ +count++ +v=el+" "+count +console.log(v) + +} +// let name="SHUBHAM" + +// let n=name.substring(0,5) + +// console.log(n) + + +// // console.log("hello")