473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Format always consistent for DateTime.ToString("s") ?

Will DateTime.Now.ToString("s") ALWAYS return the same formatting (i.e. the sortable XML Schema style formatting) regardless of what culture the operating system is set to?

I've done limited testing to show that this is the case when switching to the Italian culture, but I need to verify that in EVERY culture setting it will ALWAYS return the same format.

Thanks.

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Sep 1 '06 #1
4 14234
Greg,

Iso date notation is ISO, why would it give another format in Italy than in
the USA.
The base is exact the same and the result should be exact the same.
(Should be because I am not aware of bugs).

yyyy MM dd hh mm ss

Cor

"Greg Collins [Microsoft MVP]" <gcollins_AT_msn_DOT_comschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
Will DateTime.Now.ToString("s") ALWAYS return the same formatting (i.e. the
sortable XML Schema style formatting) regardless of what culture the
operating system is set to?

I've done limited testing to show that this is the case when switching to
the Italian culture, but I need to verify that in EVERY culture setting it
will ALWAYS return the same format.

Thanks.

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )

Sep 2 '06 #2
Sorry, I should have been a little more clear...

When I use, for example, DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"); when the operating system is set to another culture (in this example, Italian), .NET converts that formatting to the locale-specific format, and I get the time using dots instead of colons: "yyyy-MM-ddTHH.mm.ss".

Now note that I did not specify that I wanted the formatting to be using the en-US culture info.

But I also noticed that .ToString("s"), even when in the Italian culture, properly gives me the colons in the time formatting. This is essential for working with XML to avoid schema validation errors.

So my question is whether using "s", no matter what culutre the operating system is set to, will ALWAYS give the same formatting: "yyyy-MM-ddTHH:mm:ss"?

I want to be sure there's not some corner case where it will ever NOT give that same identical formattng.

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Sep 3 '06 #3
Greg Collins [Microsoft MVP] wrote:
Sorry, I should have been a little more clear...

When I use, for example,
DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"); when the operating
system is set to another culture (in this example, Italian), .NET
converts that formatting to the locale-specific format, and I get the
time using dots instead of colons: "yyyy-MM-ddTHH.mm.ss".

Now note that I did not specify that I wanted the formatting to be
using the en-US culture info.

But I also noticed that .ToString("s"), even when in the Italian
culture, properly gives me the colons in the time formatting. This is
essential for working with XML to avoid schema validation errors.

So my question is whether using "s", no matter what culutre the
operating system is set to, will ALWAYS give the same formatting:
"yyyy-MM-ddTHH:mm:ss"?

I want to be sure there's not some corner case where it will ever NOT
give that same identical formattng.
If there is such a case, it's a bug. The documentation says specifically
that it uses the format string "yyyy-MM-ddTHH:mm:ss" and use the
InvariantCulture, so it'll always be the same, regardless of the current
culture.

-cd
Sep 3 '06 #4
Great! Thanks for all your replies.

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Sep 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: cody | last post by:
Iam using Beta2 of VS2005 and getting the error "Error 4 'format-dateTime()' is an unknown XSLT function" at the following line: <xsl:value-of select="format-dateTime($pubDate,' : ')" /> ...
2
by: Sasha | last post by:
Hi, What is an easy way to create DateTime from a string that contains date in the following format "yyyyMMdd"? Take care, Sasha
1
by: John Chorlton | last post by:
I've been attempting to pass a chunk of data back from a child Windows form using public properties on the form and have been getting some odd errors. I wanted to return a row of data to avoid...
16
by: Al Reid | last post by:
First, I'm using vb2005. I have a string that is read from a barcode reader into a TextBox. The string is 6 characters long and represents a date (mmddyy). I want to display it to the user in a...
1
by: Jason Chan | last post by:
DateTime mydate = new DateTime(2006,1,1,0,0,0); string testStr = mydate.ToString("hh:mm:ss"); //return 12:00:00 mydate = new DateTime(2006,1,1,1,0,0) testStr = mydate.ToString("hh:mm:ss");...
1
by: Marc Gravell | last post by:
Just been debugging a daylight savings glitch... something that interested me: (in a BST locale at 5:14 local time, 4:14 GMT) DateTime.Now.ToString("R") >"Mon, 26 Mar 2007 05:14:34 GMT" ...
5
by: Bob | last post by:
Hello Folks, I am bring backa data reader dr from the database/ So I have a number of fields such as dr To put this in a table I use "<td>" + dr.ToString() + "</td>" But I want to...
2
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, the topic says all. I use this code from C# to call the NtQuerySystemInformation. When i call NtQuerySystemInformation the first time with zero buffer length to get the buffer size needed...
14
by: | last post by:
Hi, I program in asp.net. I have a date in TextBox in format "dd/MM/yyyy". I would like to validate if the date is realy correct. I used RegularExpressionValidator with...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.