AM/PM doesn't exist when using DateTime in a en-US environnement

V

Vilcoyote

Here is the problem. I need to display a date in the en-US format (6:00
PM and not 18:00). Theorically there are many ways to get a short date
format string from a date:
myDate.ToString("t")
myDate.ToString("h:mm tt")
myDate.ToShortTimeString()
and the most complete one:
myDate.ToString(new
CultureInfo("en-US").DateTimeFormat.ShortTimePattern)

Well none of these work properly...here are the results i get if the
time of my dateTime is 6:00 PM
myDate.ToString("t") --> 18:00
myDate.ToShortTimeString() --> 18:00
myDate.ToString("h:mm tt") --> 6:00
myDate.ToString(new
CultureInfo("en-US").DateTimeFormat.ShortTimePattern) --> 6:00

It's like the "t" symbol isn't even recognized...
int fact, if i just do DateTime.Now in the immediate window of Visual
Studio, the AM/PM doesn't show either.

Now the weirdest thing, I have a similar project where everything works
just fine (it is in fact the previous version of the same project, i
just took the class and put it in a brand new project). Both project
are done in Visual Studio 2005, DotNet 2.0, on the same computer. I can
run them at the same time, one will work (the old one) and one will
have this weird bug (the one that needs to work, of course, or it
wouldn't be fun).

If anyone has ever had that same problem, i'll be glad to know how they
solved the problem (if they did).

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top