Thursday, 15 January 2015

vb.net - How to display shortTime in 12/24 hour format depending on user's settings -



vb.net - How to display shortTime in 12/24 hour format depending on user's settings -

i have sub displays user's lastly login time. takes time user lastly logged in, converts local time , display in general short time. done by:

subitem("last_login").text = login.tostring("g", datetimeformatinfo.invariantinfo)

and correctly displays short form of date , time (in 24 hr format) user's lastly login time.

i looking alter time displayed user using application has time formatted.

for illustration if time displayed 6/18/2014 3:02 pm display in form. if time set 24-hour clock format, user see time 6/18/2014 13:02

i've tried: subitem("last_login").text = login.tostring() , works. displays longtimepattern. when add together "g" , "t" seem go off of user's part setting, not clock setting.

i tried adding new datetimeformatinfo object , using dtformat.shorttimepattern defined here, 1 time again - no luck.

in closing, getting 6/18/2014 3:14:00 pm lastly login time, need 6/18/2014 3:14 pm (what clock on taskbar shows). alternatively, if clock set 24-hour format instead of 12, i'd need see 6/18/2014 13:14 instead of 6/18/2014 13:14:00.

how can done?

edit: when debugging, check immediate window see shorttimepattern , comes h:mm tt never h:mm when clock set 24-hour format. seems main issue here.

the login details coming here subitem("last_login").text correct?

you can pass on date variable, , there convert int's format 1 specified

dim x date = subitem("last_login").text msgbox(x.tostring("mm/dd/yyyy hh:mm"))

vb.net winforms

No comments:

Post a Comment