Remove AM PM from Time String using CSharp

Remove AM PM from Time String using CSharp

Howdy Readers,

It’s always fun as well as frustration at times working with DateTime in C#.

While working with one of the application, I had a requirement to remove the trailing AM/PM from time string which we were reading from as .csv file.

If anyone out there with similar requirement, he/she can straight away refer to this post and no need to think on writing the logic.  So thought of sharing it.

Remove AM PM from Time String using CSharp

Remove AM PM from Time String using C#

 

CSV File:

Name DOJ Check in Time
Dipendra 4/15/2016 9:00:00 AM
Mahesh 4/12/2016 2:30:00 PM

Code Snippets:

Function to read data from input file:

Function to format time by stripping out AM/PM string:

Hope this post was useful and saved your time.

What do you think?

Dear Reader,
If you have any questions or suggestions, please feel free to email us or put your thoughts as comments below. We would love to hear from you. If you found this post or article useful then please share along with your friends and help them to learn.

Happy Learning :)