My datetime is showing me the seconds eventhough i have put as thisTimeSlotFrom = Value.ToShortTimeString();
I can view it from my laptop only HH:mm
. However when read from your client's pc, it show it as HH:mm:ss
.
does it relates to the time format used in my client's pc? How do i handle this to just show HH:mm ?
use Value.ToString("HH:mm")
to always get the same format, because ToShortTimeString uses the format defined on the PCs culture.
From MSDN:
DateTime.ToShortTimeString
Method
The value of the current DateTime object is formatted using the pattern defined by the DateTimeFormatInfo.ShortTimePattern property associated with the current thread culture.
DateTimeFormatInfo.ShortTimePattern
Your applications are recommended to set the short time pattern to the exact value of interest, instead of attempting to have the time separator replaced. For example, to obtain the pattern h-mm-ss, the application should set "h-mm-ss" specifically.
Or the simplest is to use this instead
TimeSlotFrom = Value.ToString("HH:mm tt")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With