C # datetime formater

Source: Internet
Author: User
Using C = system. console ;... static void main () {datetime = datetime. now; C. writeline ("d = {0: d}", datetime); // mm/DD/yyyy c. writeline ("d = {0: d}", datetime); // month DD, yyyy C. writeline ("F = {0: f}", datetime); // day, month DD, yyyy hh: mm c. writeline ("F = {0: f}", datetime); // day, month DD, yyyy hh: mm: ss am/pm c. writeline ("G = {0: g}", datetime); // mm/DD/YYYY hh: mm c. writeline ("G = {0: g}", datetime); // mm/DD/YYYY hh: mm: ss c. writeline ("m = {0: m}", datetime); // month dd C. writeline ("r = {0: R}", datetime); // DDD month yyyy hh: mm: ss gmt c. writeline ("s = {0: s}", datetime); // yyyy-mm-dd hh: mm: SS (sortable) C. writeline ("t = {0: t}", datetime); // hh: Mm AM/pm c. writeline ("t = {0: t}", datetime); // hh: mm: ss am/PM // yyyy-mm-dd hh: mm: SS (sortable) c. writeline ("u = {0: u}", datetime); // day, month DD, yyyy hh: mm: ss am/pm c. writeline ("u = {0: u}", datetime); // month, YYYY (March, 2006) C. writeline ("Y = {0: y}", datetime); C. writeline ("month =" + datetime. month); // month number (3) // day of week name (Friday) C. writeline ("day of week =" + datetime. dayofweek); // 24 hour time (16:12:11) C. writeline ("time of day =" + datetime. timeofday); // (632769991310000000) C. writeline ("datetime. ticks = "+ datetime. ticks); // ticks are the number of 100 nanosecond intervals since 01/01/0001 am // ticks are useful in elapsed time measurement .}

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.