How to Format time in

I read the date and time value from the array as:
"15-APR-2005 01:00:00 PM"

I want to grab only time and if it is PM then I want to format for 1:00:00 PM as: 1300,1400,1500 and so on...,
else if it is AM then for 1:00:00 AM I want to format as 100,200,300... and so on.

Who is Participating?
S-TwilleyConnect With a Mentor Commented:

Dim CurrentTime as DateTime
Dim sCurrentTime as String
CurrentTime = DateTime.Now

sCurrentTime = CurrentTime.ToString("H:mm")  ' if you want the colon


sCurrentTime = CurrentTime.ToString("Hmm")  ' if you don't want the colon
Assuming you are using a DateTime object, you can do something like the following:

Dim CurrentTime as DateTime
Dim CurrentMilitaryTime as String
CurrentTime = DateTime.Now

CurrentMilitaryTime = CurrentTime .Hour.ToString() & CurrentTime.Minute.ToString()

the Hour member will return a hour between 0 - 23
So, this
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.