Time settings

  • Thread starter Thread starter Edwin Loubser via .NET 247
  • Start date Start date
E

Edwin Loubser via .NET 247

Hi there,

My problem is the following: I get the current time on the machine by using Now(), but for some
weird reason this machine (happens only on this machine) refuses to show/handle the tt part of the time. Thus all the times I get using anything like Now() or even when assigning a formatted time to a variable it does not show AM/PM.

I presume this is a system settings issue, now I looked at the Date/Time & Regional Settings under the Control Panel and yet it is identical to a machine that works perfectly.

My question is thus where does VB.Net get its System Time from and where can I see the settings?
Or alternatively can anyone think of a solution to bypass this problem?

Thanx in advance
Edwin
 
Edwin,

AM/PM is only showed in cultures where that is used. That is for sure in
Australia, the USA and Canadian English and I thought the UK. I don't know
which cultures use this as well. However you have to look to the country
settings of the computer.

(You can force this as well, however be sure that you set it back to the
original to become not in problems)

A little sample

\\\
Public Class Main
Public Shared Sub Main()
Threading.Thread.CurrentThread.CurrentCulture = _
New Globalization.CultureInfo("en-AU")
'When you are not in the culture with this settingtis
MessageBox.Show(CDate("01-JUNE-2004 11:59 PM").AddDays(1).ToString)
'Above is the only thing what is needed when it is in your own culture
setting
'And set the culture back when it was not your own culture
Threading.Thread.CurrentThread.CurrentCulture = _
Globalization.CultureInfo.InstalledUICulture
End Sub
End Class
///

I hope this helps,

Cor
 
Back
Top