About the experience of date conversion

xiaoxiao2021-03-06  101

Date converted into a string almost every project work, no matter what development tool you use. Using Convert or Cast in SQL Server can be convenient to a string of various formats, in the PB, you can use String (Date, "YYYY-MM-DD") to step by step. What about ASP.NET? I found that it is always better to use, if you use YYYY-MM-DD to transform: begindate.selectedDate.Tostring (YYYY-MM-DD ", DateTimeFormatinfo.invariantIntinfo)

Then get it: 2004-00-23

Why is it 00? I'm baffled. To this end, I read the help carefully. The following code comes from ASP.NET online help.

The following example illustrates the different methods of setting a DateTime value with an invisible DateTimeFormatinfo. [Visual Basic] Option ExplicitOption Strict

Imports SystemImports System.globalization

Public Class Mainclass Public Shared Sub Main () DIM DT AS DATETIME = DATETIME.NOW DIM MyFormat () AS String = {"D", "D", _ "f", "f", _ "g", "g" , _ "M", _ "r", _ "s", _ "t", "t", _ "u", "u", _ "y", _ "DDDD, MMMM DD YYYY", _ " DDD, MMM D "" '"" YY ", _" DDDD, MMMM DD ", _" mm-yy ", _" DD-mm-yy "} Dim MyDate As String Dim I as integer for i = 0 to myFormat .Length - 1 mydate = dt.toString (MyFormat (i), datetimeformatinfo.invariantinfo) Console.writeline (String.Concat (MyFormat (i), ":", MYD ATE)) Next I

'Output.' 'D: 08/17/2000' D: Thursday, August 17, 2000 'f: Thursday, August 17, 2000 16:32' f: Thursday, August 17, 2000 16:32:32 'g: 08/17/2000 16:32 'g: 08/17/2000 16:32:32' m: August 17 'R: Thu, 17 Aug 2000 23:32:32 GMT' S: 2000-08-17T16: 32 : 32 'T: 16: 32' T: 16: 32: 32 'u: 2000-08-17 23: 32: 32Z' u: Thursday, August 17, 2000 23:32:32 'Y: August, 2000' DDDD, MMMM DD YYYY: Thursday, August 17 2000 'DDD, MMM D "" YY: THU, AUG 17 '00' DDDD, MMMM DD: Thursday, August 17 'm / YY: 8/00' DD-MM- YY: 17-08-00 End Sub 'main End Class' MAINCLASS is right, people write it is also YYYY-MM-DD format, but people can return the result correctly, I can't. Slow down, I will observe again. Is it ... Is it a case of case? That's right, when ASP.NET is just released, it will declare that the case is gradually referred to an important position, completely change the chaotic state of case where the ASP era is case sensitive. That is, the MM here is to write into MM. I have a try to see the psychological changes, pass it over and over, and you can success return 2004-08-23. I can't end this, I immediately changed to uppercase: YYYY-MM-DD, and the results found that returning YYYY-08-DD, that is, YYYY-MM-DD is the only scheme that is available.

Many friends are learning from the process of learning, what should I do? What should I do? In fact, the help of development tools, you have to lick. Because the information helps can fully meet your basic needs. Imagine, if the help is not written, then everyone will learn this development tool, then who is preparing to sell the development tool? In particular, Microsoft is helpful, and the degree of cultural degree and the degree of detail have become a point where it is.

转载请注明原文地址:https://www.9cbs.com/read-124402.html

New Post(0)