Time format

J

Just D

Did anybody see this bug? I tried to reproduce that using 12-hour and
24-hour system settings. Anyway it still causes a problem in VS2003. When I
convert DateTime to a string using default ToString(), like
DateTime.Now.ToString() C# returns me this string instead of a correct one:
"19:25:35 PM". That's nonsense, but when I try to use
DateTime.Parse(ThisString) it causes a fatal error, because this string
doesn't look like as a time string. What's the matter?

Thanks,
Dmitri
 
J

Just D

By the way, I can format this time manually in most cases, maybe excluding a
few cases like this:

dtCalDate = DateTime.Parse(Request["CalDate"]);

Thanks,
Dmitri
 
J

John Baro

03/06/2004 1:22:58 PM (using 12 hour clock)
03/06/2004 13:26:10 PM (using 24 hour clock)
I get the same problem :(

However, when I go to regional settings and change the time format from
HH:mm:ss tt to HH:mm:ss (remove tt) I get the correct result.
03/06/2004 13:29:00
DateTime.ToString is therefore right because it is supposed to return a
datetime based on the system short datetime format.
Check your regional settings.

JB

Just D said:
By the way, I can format this time manually in most cases, maybe excluding a
few cases like this:

dtCalDate = DateTime.Parse(Request["CalDate"]);

Thanks,
Dmitri

Just D said:
Did anybody see this bug? I tried to reproduce that using 12-hour and
24-hour system settings. Anyway it still causes a problem in VS2003. When
I convert DateTime to a string using default ToString(), like
DateTime.Now.ToString() C# returns me this string instead of a correct
one: "19:25:35 PM". That's nonsense, but when I try to use
DateTime.Parse(ThisString) it causes a fatal error, because this string
doesn't look like as a time string. What's the matter?
 
J

Just D

Hi John,

Yes, I was playing with the regional settings and noticed that sometimes it
doesn't help. That's very strange but fact. When I noticed this problem
first time I tried to correct these settings for my local system. I like to
work at night, and everything was looking good, until the time rolled over
12 hours when I was working afternoon.

I suspect that the problem is much deeper and we need to correct the
DateTime.Parse() method. I can try to correct this one replacing all calls
in my code with my method, but... as you understand, sometimes it can't be
solved. It should be solved at the lowest level instead.

Thanks,
Dmitri

"John Baro"
03/06/2004 1:22:58 PM (using 12 hour clock)
03/06/2004 13:26:10 PM (using 24 hour clock)
I get the same problem :(

However, when I go to regional settings and change the time format from
HH:mm:ss tt to HH:mm:ss (remove tt) I get the correct result.
03/06/2004 13:29:00
DateTime.ToString is therefore right because it is supposed to return a
datetime based on the system short datetime format.
Check your regional settings.
Just D said:
By the way, I can format this time manually in most cases, maybe
excluding a
few cases like this:

DateTime.Parse(Request["CalDate"]);

Thanks,
Dmitri

Just D said:
Did anybody see this bug? I tried to reproduce that using 12-hour and
24-hour system settings. Anyway it still causes a problem in VS2003. When
I convert DateTime to a string using default ToString(), like
DateTime.Now.ToString() C# returns me this string instead of a correct
one: "19:25:35 PM". That's nonsense, but when I try to use
DateTime.Parse(ThisString) it causes a fatal error, because this string
doesn't look like as a time string. What's the matter?
 

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

Top