473,396 Members | 1,936 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,396 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 14241
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.