Summary of ASP. NET MVC Time Format transformation

Source: Internet
Author: User
Tags truncated

1. You need to read the value of the DateTime type from the database and assign the value to the "datetime-local" control as the default value:

<input type= "datetime-local" name= "EndTime" id= "EndTime" value= "@Model. Endtime.tostring (" yyyy-mm-ddthh:mm ")"/ >

Note: (1) Uppercase HH denotes 24-hour system, lowercase hh denotes 12-hour (2) format string, "yyyy-mm-ddthh:mm" T must be written, otherwise this control does not recognize (3) the formatting process must be written in the view, or it will be an error

2.

DateTime.Parse (List[i]. EndTime). ToString ("Yyyy-mm-dd hh:mm")

The format above is cast to a datetime type in a datetime form of string type

3.c# Time Mode Description: "yyyy-mm-ddthh:mm"

A day in the D month. One-digit date has no leading zeros.
DD a day of the month. A one-digit date has a leading zero.
The abbreviated name of the day of the DDD week, defined in Abbreviateddaynames.
dddd the full name of the day of the week, as defined in DayNames.
M-month number. One-digit month has no leading zeros.
MM Month number. One-digit month has a leading zero.
Abbreviated name of the MMM month, defined in AbbreviatedMonthNames.
The full name of the mmmm month, as defined in MonthNames.
Y does not contain the year of the era. If the year that does not contain an era is less than 10, the year is displayed without leading zeros.
YY does not contain the year of the era. If the year that does not contain an era is less than 10, the year with leading zeros is displayed.
The YYYY includes the four-digit year of the era.
GG period or ERA. If the date to be formatted does not have an associated period or era string, the pattern is ignored.
Hours of H12 hours. One-digit hours do not have leading zeros.
Hours of hh12 hours. One-digit hours have leading zeros.
Hours of H24 hours. One-digit hours do not have leading zeros.
Hours of HH24 hours. One-digit hours have leading zeros.
M minutes. A single-digit number of minutes does not have a leading zero.
MM minutes. A single-digit number of minutes has a leading zero.
s seconds. The number of seconds in a single digit does not have a leading zero.
SS seconds. The number of seconds of one digit has a leading zero.
The fractional precision of the F-second is one digit. The remaining digits are truncated.
The fractional precision of the FF seconds is two bits. The remaining digits are truncated.
The fractional precision of FFF seconds is three bits. The remaining digits are truncated.
The fractional precision of ffff seconds is four bits. The remaining digits are truncated.
The fractional precision of fffff seconds is five bits. The remaining digits are truncated.
The fractional precision of ffffff seconds is six bits. The remaining digits are truncated.
The fractional precision of fffffff seconds is seven bits. The remaining digits are truncated.
t the am/pm defined in AMDesignator or PMDesignator indicates the first character of the item, if one exists.
The AM/PM indicated by the TT in AMDesignator or PMDesignator (if present).
The Z Time zone offset ("+" or "-" followed by hours only). One-digit hours do not have leading zeros. For example, Pacific Standard Time is "-8".
ZZ Time zone offset ("+" or "-" followed by hours only). One-digit hours have leading zeros. For example, Pacific Standard Time is "-08".
The ZZZ Full time zone offset ("+" or "-" followed by hours and minutes). The number of hours and minutes of a single digit has a leading zero. For example, Pacific Standard Time is " -08:00".
: The default time delimiter defined in TimeSeparator.
/The default date delimiter defined in DateSeparator.
%c where C is the format pattern (if used alone). You can omit the "%" character if the format pattern is merged with literal characters or other format patterns.
c where c is any character. Displays the characters as they are originally defined. To display the backslash character, use.
Only the format patterns listed in the second table above can be used to create custom patterns, and the standard format characters listed in the first table cannot be used to create custom patterns. The custom pattern is at least two characters long;
DateTime.ToString ("D") returns a DateTime value; "D" is a standard short date pattern.
DateTime.ToString ("%d") returns the day of the month; "%d" is a custom pattern.
DateTime.ToString ("D") returns the day of the month followed by a blank character, and "D" is a custom pattern.

Summary of ASP. NET MVC Time Format transformation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.