About the date display and input

xiaoxiao2021-03-05  24

Originally published in chinaspx.com] I didn't want to format this problem. Because there is a detailed introduction in the SDK document in VS.NET. I am afraid that there is a suspect to be aimed. But there is no one in the forum. Ask this question, I will use a simple introduction here (here you have a friend who doesn't know much about the date format. MS-help: //ms.netframeworksdkv1.1.chs/vblr7net/html/vafmtuserDefinedDateFormats .htm is the detailed documentation in the SDK. 1) Date formatted display in the specified form of the 8-bit length date in SQL 2003-12-31 00:00:00

The most commonly used in ASP.NET is only part of 2003-12-31, you can use DateTime.now.tostring ("D") or datetime.now.toshortdateString (); but the specific format is 2003/12/31 or If you want to see where your system configuration date is configured. You want to determine how to get 2003-12-31 specified. TOSTRING () user custom format format can look at the document Returns 2003-11-25 .tostring ("YYYYMMDD") Returns 20031125 [Document from the SDK] D will show the day as a digital number (such as 1) . If this is a unique character in the user-defined digital format, use% D. DD will display the day as a digital (such as 01). DDD will display the day as an abbreviated form (for example, Sun). DDDD will display the day as a full name (such as Sunday). M The month is displayed as a digital number without lead-guided zero (as shown in Jan). If this is the unique character in the user-defined digital format, use% M. MM displays the month as a front guide (for example 01/12/01). MMM displays the month as an abbreviation form (for example, JAN). MMMM displays the month as a full month name (such as January). The GG display era / era string (such as A.D.) h displays the hour to display the digital (for example, 1: 15: 15 pm). If this is the unique character in the user-defined digital format, use% H. HH uses 12 hours to display the hour to the front guide (for example, 01:15:15 pm). H Display the hour to use the 24-hour system to display the digital (for example, 1:15:15). If this is the unique character in the user-defined digital format, use% H. HH uses 24-hour system to display a number with a leading zero (for example, 01:15:15). M Display the minutes as numbers without leading zero (for example, 12: 1: 15). If this is the unique character in the user-defined digital format, use% M. The mm displays a number with a leading zero (eg 12: 01:15). S The second is displayed as a number without lead-guided zero (for example, 12: 15: 5). If this is the unique character in the user-defined digital format, use% s. SS displays the seconds of the front guide (for example, 12:15:05). F shows the fractional part of the second. For example, FF will exactly display one second, and FFFF will exactly displays a thousand seconds. User-defined formats can use the seven F symbols. If this is the unique character in the user-defined digital format, use% F. T use 12 hours, and the uppercase is displayed at any hour before noon, and the upper-write P is displayed at any hour of noon to 11:59 p.m. If this is the unique character in the user-defined digital format, use% T. TT uses 12 hours of use, and the uppercase is displayed on any hour before noon; the upper-write PM is displayed at any hour between noon to 11:59 p.m. Y Displayed the number (0-9) as a number without lead-guided zero. If this is a unique character in the user-defined digital format, use% Y.

YY displays the year (if applicable) with a lead-zero two digital format. YYY shows the year in four digits format. YYYY shows the year in four digits format. Z Displays the time zone offset (such as -8) without a leading zero. If this is a unique character in the user-defined digital format, use% Z. Zz Display Time Zone Offset (for example, -08) ZZZ displays a complete time zone offset (for example, -08: 00), the same for time can also be formatted .. You can use custom formats to set up You want the format output. You can use the characters in the above table whether you have no matter how much you write YYYY-YYY, it is possible. However, I don't think there is not much boring person. Quite free pay attention is that the format must be the date DateTime format .. The type in SQL is the same. Otherwise, the format is invalid or error. Especially in the format of the DataGrid {0: ifromat} 2) The date of the date is usually used in the date format. It is quite limited to this form. Some of the conversions are quite limited. Some C # is not understanding the date format you write. If you are 2003-12-31 No. C # doesn't know him. We can do this // set the language country system.iformprovider format = new system.globalization.cultureInfo ("zh-cn", true); // Specify conversion format response.write (DateTime. Parseexact (this.textBox1.text, "YYYYMMDD", FORMAT)); so he can see the date format of 20031231, but unfortunately he can only convert the YYYYMMDD to other formats, is it uniform? But .NET Another overload version is provided. Public Static DateTime Parsexact (String, String [], IFORMATPROVIDER, DATETIMESTYLES); converts the specified date format conversion. However, the specific operation I want to go to the test, it is possible Will be better

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

New Post(0)