-
Incorrect Time Display
Code:
Dim TestTime As DateTime
TestTime = Convert.ToDateTime("12:00:00")
Dim TestString As String = FormatDateTime(TestTime, DateFormat.LongTime)
Debug.WriteLine(TestString & " <<--Error")
debug output - a correct statement
12:00:00 PM <<--Error
0002, is the lonliest number... apologies to Three Dog Night
-
Re: Incorrect Time Display
what output are you expecting?
-
Re: Incorrect Time Display
The correct one, how about you?:wave:
0002, is the lonliest number... apologies to Three Dog Night
-
Re: Incorrect Time Display
well that is what I am asking you, what do you think the correct output should be
-
Re: Incorrect Time Display
and please don't say it should be AM...
-
Re: Incorrect Time Display
What are you looking for as far as the output is concerned? I ran this code and got the correct result.
The Convert.ToDateTime() function is using a 24-Hour clock. So, if you want 12:00 AM the code would be:
Code:
Dim TestTime As DateTime
TestTime = Convert.ToDateTime("00:00:00")
Dim TestString As String = FormatDateTime(TestTime, DateFormat.LongTime)
Debug.WriteLine(TestString & " <<--Error")
Or, you can also write it as:
Code:
Dim TestTime As DateTime
TestTime = Convert.ToDateTime("12:00:00 AM")
Dim TestString As String = FormatDateTime(TestTime, DateFormat.LongTime)
Debug.WriteLine(TestString & " <<--Error")
Either of these examples will give you a result of 12:00 AM
-
Re: Incorrect Time Display
and please I won't. To tell the truth it should say error here
TestTime = Convert.ToDateTime("12:00:00")
Since there was a discussion about whether 0002 was number or not, I thought I would bring this up.
Simply put, 12AM / 12PM and relatives (12:00:00 AM / 12:00:00 PM) are nonsense. I acknowledge that a lot of people know what is meant by that, but I am not one of them.
-
Re: Incorrect Time Display
I don't understand the problem. Check your computers regional settings:
Code:
LongTime
vbLongTime
Displays a time using the long-time format specified in your computer's regional settings
-
Re: Incorrect Time Display
yeah, as VisualAd says, its all based on your PC settings...
Lots of countries use , instead of . with numbers
1,000,000.50
1.000.000,50
Or dates are written
03/05/2008
05/03/2008
If you don't know what culture you are using, then it is impossible to know if the date is march 5th, or may 3rd. However based on the culture, there are rules that govern the correct order of things.
-
Re: Incorrect Time Display
Google -->>> noon midnight PM AM
-
Re: Incorrect Time Display
Quote:
Originally Posted by LloydAZ
What are you looking for as far as the output is concerned? I ran this code and got the correct result.
The Convert.ToDateTime() function is using a 24-Hour clock. So, if you want 12:00 AM the code would be:
Code:
Dim TestTime As DateTime
TestTime = Convert.ToDateTime("00:00:00")
Dim TestString As String = FormatDateTime(TestTime, DateFormat.LongTime)
Debug.WriteLine(TestString & " <<--Error")
Or, you can also write it as:
Code:
Dim TestTime As DateTime
TestTime = Convert.ToDateTime("12:00:00 AM")
Dim TestString As String = FormatDateTime(TestTime, DateFormat.LongTime)
Debug.WriteLine(TestString & " <<--Error")
Either of these examples will give you a result of 12:00 AM
google, google, google. --->> noon midnight PM AM
You said "I ran this code and got the correct result." I think you ran the code and got an answer you expected.
-
Re: Incorrect Time Display
This thread really confuses me. Are we speaking in riddles?
-
Re: Incorrect Time Display
Quote:
Originally Posted by kleinma
yeah, as VisualAd says, its all based on your PC settings...
Lots of countries use , instead of . with numbers
1,000,000.50
1.000.000,50
Or dates are written
03/05/2008
05/03/2008
If you don't know what culture you are using, then it is impossible to know if the date is march 5th, or may 3rd. However based on the culture, there are rules that govern the correct order of things.
But don't I have a right for the result to be correct for my regional settings.
Like I said, in the spirit of 002, I brought this up. I don't deal with this. I always use military time (wonder why they do) and get clarifiaction if we are going to meet at 12AM / 12PM. It is just sad that Microsoft can't tell time.
-
Re: Incorrect Time Display
Quote:
Originally Posted by Atheist
This thread really confuses me. Are we speaking in riddles?
I was doing a 002. If you want to know just google > noon midnight PM AM
-
Re: Incorrect Time Display
honestly I still fail to see what you are saying here....
You have yet to claim what you THINK the output should be.... we all think there is no issue.
So if you think there actually is an issue, you need to say "The output should be this: x, and this is why, x"
-
Re: Incorrect Time Display
This discussion is also happening in another thread (where there was also a lack of explanation of the 'problem'): http://www.vbforums.com/showthread.php?t=512121
dbasnett is referring to the fact that while there is a common understanding of what 12:00:00 AM means, to be extremely picky it is technically not valid (it should be "midnight"), but 12:00:01 AM is valid for a second later.
-
Re: Incorrect Time Display
Either of these would be better, but not definitive.
Code:
Dim TestTime As DateTime
TestTime = Convert.ToDateTime("12:00:00 Noon")
Dim TestString As String = FormatDateTime(TestTime, DateFormat.LongTime)
Debug.WriteLine(TestString)
debug output -> 12:00:00 Noon
or
Dim TestTime As DateTime
TestTime = Convert.ToDateTime("12:00:00 Midnight")
Dim TestString As String = FormatDateTime(TestTime, DateFormat.LongTime)
Debug.WriteLine(TestString)
debug output -> 12:00:00 Midnight
If I say lets meet at 12PM March 5th, when do I want to meet? At the boundary between march 5 - 6 or 4 - 5?
-
Re: Incorrect Time Display
I googled like you requested.
In theory it makes sense. But think of it this way as well:
1 nanosecond past midnight would make it AM and one nanosecond past noon would make it PM.
From a programming perspective, I would have to say that the answer that the application gives is correct. Trying to determine that the precise moment in time is exactly 00:00:00 or 12:00:00 is a little beyond what is expected.
-
1 Attachment(s)
Re: Incorrect Time Display
it all comes down to culture.... the American culture uses AM/PM. So if you pick USA when you installed windows when it asks for your region, you get AM/PM time.
If you live in some other country where they don't use AM/PM, then you would have picked that country, and the regional settings would be set accordingly, never showing you AM or PM for times because you don't know what they mean.
And if you live in America, and you don't know what AM and PM are in terms of time, then the school system failed horribly.
You can of course customize Windows to display the date/time however you want.
-
Re: Incorrect Time Display
If it isn't obvious I have thought about this before. My issue is an American issue, and one that I have resolved for myself through the use of military time.
Sorry that I thought it might be fun to discuss this here, it isn't. I'm done.
-
Re: Incorrect Time Display
In 24-hour time format (without AM/PM), 12:00:00 represents midday so when converted to AM/PM format it will become 12:00:00 PM.
In 24-hour time format (without AM/PM), 00:00:00 represents midnight so when converted to AM/PM format it will become 12:00:00 AM.
Are your bosses paying you for doing this stuff?
-
Re: Incorrect Time Display
Yes I am paying myself.
http://iconlogic.blogs.com/weblog/20...g-works-1.html
I feel better knowing that there are a few billion people with the same issue ;-)
http://forum.kasperskyclub.com/blog/...?showentry=272
"And if you live in America, and you don't know what AM and PM are in terms of time, then the school system failed horribly." What does that mean?
Are you speaking generally or in the particular case of 12AM / 12PM? If in general I wasn't failed, I know the difference between 1AM / 1PM. If, as I am guessing, you mean 12AM / 12PM maybe it isn't my school that failed. Could it be that the schools I attended knew that 12AM / 12PM were incorrect?
For the record, it was my 9th grade Geometry teacher that started this. It was during a time when accepted did not mean right(Civil Rights). Maybe you read about it in History class.
FYI - I submitted this to MSDN as a Suggestion. My instinct tells me it will be ignored by Microsoft.
-
Re: Incorrect Time Display
Quote:
Originally Posted by dbasnett
If I say lets meet at 12PM March 5th, when do I want to meet? At the boundary between march 5 - 6 or 4 - 5?
Neither.
-
Re: Incorrect Time Display
Quote:
Originally Posted by dbasnett
If I say lets meet at 12PM March 5th, when do I want to meet? At the boundary between march 5 - 6 or 4 - 5?
Noon on the 5th. What's the 4th or 6th got to do with it? Leave them out of it. They didn't do anything to you.
-tg
-
Re: Incorrect Time Display
So far it(see post #23) has been ignored by Microsoft. Now there is a shock.
-
Re: Incorrect Time Display
To display it as military time, you need to use capital H's in the format:
Code:
Dim TestTime As DateTime
TestTime = Convert.ToDateTime("12:00:00")
Dim TestString As String = String.Format("{0:HH:mm}", TestTime)
Debug.WriteLine(TestString & " <<--Error")
That will get you 12:00 without am or pm