Code of various time and date formats

Source: Internet
Author: User

Console. writeline ("------------------------ standard and custom Time Format String -----------------------------"); </P> <p> 128 datetime date = new datetime (2010, 4, 5, 18, 8, 8, 16); </P> <p> 129 </P> <p> 130/d short date </P> <p> 131 console. writeline ("d short date"); </P> <p> 132 console. writeline (date. tostring ("D"); // 4/5/2010 </P> <p> 133 console. writeline (date. tostring ("D", new cultureinfo ("de-de "))); // 05.04.2010 </P> <p> 134 </P> <p> 135/D long date </P> <p> 136 console. writeline ("D long date"); </P> <p> 137 console. writeline (date. tostring ("D"); // Monday, 1_l 05,201 0 </P> <p> 138 console. writeline (date. tostring ("D", new cultureinfo ("Es-mx"); // lunes, 05 de abril de 2010 </P> <p> 139 </P> <p> 140 // F full date short time </P> <p> 141 console. writeline ("f complete date short time"); </P> <p> 142 console. writeline (date. tostring ("F"); // Monday, 2017l 05,201 0 PM </P> <p> 143 </P> <p> 144 // F full date long time </P> <p> 145 console. writeline ("f full date long time"); </P> <p> 146 console. writeline (date. tostring ("F"); // Monday, 2017l 05,201 0 6:08:08 </P> <p> 147 </P> <p> 148 // G conventional date short time </P> <p> 149 console. writeline ("G regular date short time"); </P> <p> 150 console. writeline (date. tostring ("G"); // 4/5/2010 PM </P> <p> 151 console. writeline (date. tostring ("g", datetimeformatinfo. invariantinfo )); // 04/05/2010 </P> <p> 152 </P> <p> 153 // G regular date long time </P> <p> 154 console. writeline ("G regular date long time"); </P> <p> 155 console. writeline (date. tostring ("G ")); // 4/5/2010 6:08:08 </P> <p> 156 </P> <p> 157 // m or m monthly format </P> <p> 158 console. writeline ("m or M month format"); </P> <p> 159 console. writeline (date. tostring ("M ")); // 10000l 05 </P> <p> 160 </P> <p> 161 // o or O round-trip date/time pattern </P> <p> 162 console. writeline ("O or O round-trip date/time pattern"); </P> <p> 163 console. writeline (date. tostring ("O"); // 2010-04-05t18: 08: 08.0160000 </P> <p> 164 </P> <p> 165 // R or R rfc1123 format </P> <p> 166 console. writeline ("R or R rfc1123 format"); </P> <p> 167 console. writeline (date. tostring ("R"); // Mon, 05 APR 2010 18:08:08 GMT </P> <p> 168 </P> <p> 169/s sortable format </P> <p> 170 console. writeline ("s sorting format"); </P> <p> 171 console. writeline (date. tostring ("S"); // 2010-04-05t18: 08: 08 </P> <p> 172 </P> <p> 173 // T short time format </P> <p> 174 console. writeline ("T short time format"); </P> <p> 175 console. writeline (date. tostring ("T ")); // PM </P> <p> 176 </P> <p> 177/t long time format </P> <p> 178 console. writeline ("t long time format"); </P> <p> 179 console. writeline (date. tostring ("T ")); // 6:08:08 </P> <p> 180 </P> <p> 181 // General sortedformat </P> <p> 182 console. writeline ("U common sortedformat"); </P> <p> 183 console. writeline (date. tostring ("U"); // 2010-04-05 18: 08: 08z </P> <p> 184 </P> <p> 185 // general format </P> <p> 186 console. writeline ("U universal complete format"); </P> <p> 187 console. writeline (date. tostring ("U"); // Monday, 10000l 05,201 0 10:08:08 am </P> <p>

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.