|
-
Jan 27th, 2012, 10:42 AM
#1
Thread Starter
Junior Member
[RESOLVED] Getting only Time from datetimepicker
Hi guys,
I'm having a little problem trying to figure out how to get only the time from a datetimepicker.
I've set up a datetimepicker to only allow user selection of time by setting Format to Time and ShowUpDown to True.
However, when I store the value of the datetimepicker to a variable, it returns a date as well.
vb.net Code:
JustTime = DateTimePicker1.Value
I tried to get around the issue by using:
vb.net Code:
JustTime = DateTimePicker1.Value.hour & ":" & DateTimePicker1.Value.minute & ":" & DateTimePicker1.Value.second
However, this seems like a really inelegant solution and I can't figure out how to get an AM/PM behind that.
I feel like I'm missing some really simple solution that I'm just not seeing! There HAS to be a way to get just the time!
If anyone could help me out, it would be most appreciated!
-
Jan 27th, 2012, 10:55 AM
#2
Re: Getting only Time from datetimepicker
vb Code:
DateTimePicker1.Value.tostring("HH:mm:ss")
-
Jan 27th, 2012, 11:00 AM
#3
Thread Starter
Junior Member
Re: Getting only Time from datetimepicker
 Originally Posted by make me rain
vb Code:
DateTimePicker1.Value.tostring("HH:mm:ss")
Thank you for the reply, make me rain. That is definitely way neater than my method, but it still doesn't display am/pm.
Edit: I don't know why I didn't think of this before, but I just tried DateTimePicker1.text and it worked!!!!
-
Jan 27th, 2012, 11:02 AM
#4
Re: Getting only Time from datetimepicker
Code:
DateTimePicker1.Value.ToLongTimeString()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|