C # display ZZ in datetime format

Source: Internet
Author: User

C #DatetimeDate Format display

Reprinted from: http://blog.csdn.net/angleoldhen/archive/2006/10/16/1336940.aspx


1. Date Format Method for binding:
<Asp: boundcolumn datafield = "jointime" dataformatstring = "{0: yyyy-mm-dd}">
<Itemstyle width = "18%" type = "option" text = "option"> </itemstyle>
</ASP: boundcolumn>

2. How to format data items such as DataGrid and datalist:
E. Item. Cell [0]. Text = convert. todatetime (E. Item. Cell [0]. Text). to1_datestring ();

3. Convert the date display format with the string type:
String. Format ("yyyy-mm-dd", yourdatetime );

4. Convert the date display format using the convert method:
Convert. todatetime ("2005-8-23"). tostring

("Yymmdd", system. Globalization. datetimeformatinfo. invariantinfo); // supports traditional Chinese databases.

5. Convert the date display format directly using the tostring method:
Datetime. Now. tostring ("yyyymmddhhmmss ");
Datetime. Now. tostring ("yyyy/mm/dd hh: mm: SS ")

6. show only the year and month
Databinder. eval (container. dataitem, "starttime", "{0: yyyy-m }")

7. display all time parts, including: year, month, day, hour, minute, and second
<Asp: boundcolumn datafield = "receipt time" headertext = "receipt time"
Dataformatstring = "{0: yyyy-mm-dd hh24: mm: SS}">
</ASP: boundcolumn>

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.