Link to home
Start Free TrialLog in
Avatar of monacoassociates
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?
ASKER CERTIFIED SOLUTION
Avatar of Taconvino
Taconvino

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rettiseert
rettiseert

Also, you can use FormatDateTime function and get the time formated automatically to the system settings:

txtTimeS = FormatDateTime( Time(), vbLongTime )
For just use this:

Format$(Now, "H:nn:ss AMPM")


This would produce:

10:45:30 AM
Avatar of monacoassociates

ASKER

Thanks for all the good suggestions.  I am going to accept Taconvino's solution as we sell our software internationally.