473,763 Members | 5,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Format always consistent for DateTime.ToStri ng("s") ?

Will DateTime.Now.To String("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 14270
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_ms n_DOT_comschree f in bericht
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Will DateTime.Now.To String("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.To String("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.To String("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
InvariantCultur e, 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
11540
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,' : ')" /> how can I get around this?
2
6360
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
4016
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 creating many public properties on the form to do the same thing. At first I tried returning a DataViewRow. This worked fine until I reached the phone field on the parent table and the code Child form public DataRowView SelectedAddres ge ...
16
4021
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 date format of "mm/dd/yy" For example the barcode contains "112303" and I want to format it to display "11/23/03" If I use the microsoft.visualbasic.strings.format with a format string of "##/##/##" or "00/00/00" I get the format string in the...
1
2765
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"); //return 01:00:00 I want "00:00:00" instead of "12:00:00", what is going wrong?
1
8832
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" However... DateTime.Now.IsDaylightSavingTime() >true
5
70458
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 format the number as mentioned in the subject line.
2
3048
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 for the information i get a STATUS_INFO_LENGTH_MISMATCH which is -1073741820 in number, this is ok, but why does the function not store the required
14
15326
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 ValidationExpression="//", but user can write date "31/02/2000" and validator says that it is correct (everybody know that Febuary has 28 or 29 days).
0
9387
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8822
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.