monacoassociates
asked on
time format hh:mm:ss tt yields time like 10:45:30 tt--not am or pm
We have recently upgraded our application from Visual Basic 4 to Visual Basic 6. A text box shows the time, utilizing the format set in the control panel Regional and Language Options. With the time set to h:mm:ss tt, instead of showing AM or PM, the text box displays the "tt" literal. The display was working correctly in VB4; this problem started just since the upgrade.
Here is the code we are using to get the time format:
dl& = GetLocaleInfo(LOCALE_USER_ DEFAULT, LOCALE_STIMEFORMAT, buffer, 99)
myLocale.TimeFormat = LPSTRToVBString(buffer)
txtTimeS = Format$(Time$, myLocale.TimeFormat)
Does anyone have any idea what is going on or what to do about it?
Here is the code we are using to get the time format:
dl& = GetLocaleInfo(LOCALE_USER_
myLocale.TimeFormat = LPSTRToVBString(buffer)
txtTimeS = Format$(Time$, myLocale.TimeFormat)
Does anyone have any idea what is going on or what to do about it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For just use this:
Format$(Now, "H:nn:ss AMPM")
This would produce:
10:45:30 AM
Format$(Now, "H:nn:ss AMPM")
This would produce:
10:45:30 AM
ASKER
Thanks for all the good suggestions. I am going to accept Taconvino's solution as we sell our software internationally.
txtTimeS = FormatDateTime( Time(), vbLongTime )