{"id":102,"date":"2009-12-31T09:24:06","date_gmt":"2009-12-31T09:24:06","guid":{"rendered":"http:\/\/blog.rabihtawil.com\/?p=102"},"modified":"2010-07-22T13:45:34","modified_gmt":"2010-07-22T13:45:34","slug":"datetimetostring-patterns","status":"publish","type":"post","link":"http:\/\/www.raytawil.com\/?p=102","title":{"rendered":"DateTime.ToString() Patterns"},"content":{"rendered":"<p><strong>All the patterns:<\/strong><\/p>\n<p>0 \tMM\/dd\/yyyy \t08\/22\/2006<br \/>\n1 \tdddd, dd MMMM yyyy \tTuesday, 22 August 2006<br \/>\n2 \tdddd, dd MMMM yyyy \tHH:mm Tuesday, 22 August 2006 06:30<br \/>\n3 \tdddd, dd MMMM yyyy \thh:mm tt Tuesday, 22 August 2006 06:30 AM<br \/>\n4 \tdddd, dd MMMM yyyy \tH:mm Tuesday, 22 August 2006 6:30<br \/>\n5 \tdddd, dd MMMM yyyy \th:mm tt Tuesday, 22 August 2006 6:30 AM<br \/>\n6 \tdddd, dd MMMM yyyy HH:mm:ss \tTuesday, 22 August 2006 06:30:07<br \/>\n7 \tMM\/dd\/yyyy HH:mm \t08\/22\/2006 06:30<br \/>\n8 \tMM\/dd\/yyyy hh:mm tt \t08\/22\/2006 06:30 AM<br \/>\n9 \tMM\/dd\/yyyy H:mm \t08\/22\/2006 6:30<br \/>\n10 \tMM\/dd\/yyyy h:mm tt \t08\/22\/2006 6:30 AM<br \/>\n10 \tMM\/dd\/yyyy h:mm tt \t08\/22\/2006 6:30 AM<br \/>\n10 \tMM\/dd\/yyyy h:mm tt \t08\/22\/2006 6:30 AM<br \/>\n11 \tMM\/dd\/yyyy HH:mm:ss \t08\/22\/2006 06:30:07<br \/>\n12 \tMMMM dd \tAugust 22<br \/>\n13 \tMMMM dd \tAugust 22<br \/>\n14 \tyyyy&#8217;-&#8216;MM&#8217;-&#8216;dd&#8217;T&#8217;HH&#8217;:&#8217;mm&#8217;:&#8217;ss.fffffffK \t2006-08-22T06:30:07.7199222-04:00<br \/>\n15 \tyyyy&#8217;-&#8216;MM&#8217;-&#8216;dd&#8217;T&#8217;HH&#8217;:&#8217;mm&#8217;:&#8217;ss.fffffffK \t2006-08-22T06:30:07.7199222-04:00<br \/>\n16 \tddd, dd MMM yyyy HH&#8217;:&#8217;mm&#8217;:&#8217;ss &#8216;GMT&#8217; \tTue, 22 Aug 2006 06:30:07 GMT<br \/>\n17 \tddd, dd MMM yyyy HH&#8217;:&#8217;mm&#8217;:&#8217;ss &#8216;GMT&#8217; \tTue, 22 Aug 2006 06:30:07 GMT<br \/>\n18 \tyyyy&#8217;-&#8216;MM&#8217;-&#8216;dd&#8217;T&#8217;HH&#8217;:&#8217;mm&#8217;:&#8217;ss \t2006-08-22T06:30:07<br \/>\n19 \tHH:mm \t06:30<br \/>\n20 \thh:mm tt \t06:30 AM<br \/>\n21 \tH:mm \t6:30<br \/>\n22 \th:mm tt \t6:30 AM<br \/>\n23 \tHH:mm:ss \t06:30:07<br \/>\n24 \tyyyy&#8217;-&#8216;MM&#8217;-&#8216;dd HH&#8217;:&#8217;mm&#8217;:&#8217;ss&#8217;Z&#8217; \t2006-08-22 06:30:07Z<br \/>\n25 \tdddd, dd MMMM yyyy HH:mm:ss \tTuesday, 22 August 2006 06:30:07<br \/>\n26 \tyyyy MMMM \t2006 August<br \/>\n27 \tyyyy MMMM \t2006 August<\/p>\n<p><strong>The patterns for DateTime.ToString ( &#8216;d&#8217; ) :<\/strong><\/p>\n<p>0 \tMM\/dd\/yyyy \t08\/22\/2006<br \/>\n<strong>The patterns for DateTime.ToString ( &#8216;D&#8217; ) :<\/strong><br \/>\n0 \tdddd, dd MMMM yyyy \tTuesday, 22 August 2006<\/p>\n<p><strong>The patterns for DateTime.ToString ( &#8216;f&#8217; ) :<\/strong><\/p>\n<p>0 \tdddd, dd MMMM yyyy HH:mm \tTuesday, 22 August 2006 06:30<br \/>\n1 \tdddd, dd MMMM yyyy hh:mm \ttt Tuesday, 22 August 2006 06:30 AM<br \/>\n2 \tdddd, dd MMMM yyyy H:mm \tTuesday, 22 August 2006 6:30<br \/>\n3 \tdddd, dd MMMM yyyy h:mm \ttt Tuesday, 22 August 2006 6:30 AM<br \/>\n<strong>The patterns for DateTime.ToString ( &#8216;F&#8217; ) :<\/strong><br \/>\n0 \tdddd, dd MMMM yyyy HH:mm:ss \tTuesday, 22 August 2006 06:30:07<br \/>\n<strong>The patterns for DateTime.ToString ( &#8216;g&#8217; ) :<\/strong><br \/>\n0 \tMM\/dd\/yyyy HH:mm \t08\/22\/2006 06:30<br \/>\n1 \tMM\/dd\/yyyy hh:mm \ttt 08\/22\/2006 06:30 AM<br \/>\n2 \tMM\/dd\/yyyy H:mm \t08\/22\/2006 6:30<br \/>\n3 \tMM\/dd\/yyyy h:mm tt \t08\/22\/2006 6:30 AM<br \/>\n<strong>The patterns for DateTime.ToString ( &#8216;G&#8217; ) :<\/strong><br \/>\n0 \tMM\/dd\/yyyy HH:mm:ss \t08\/22\/2006 06:30:07<br \/>\n<strong>The patterns for DateTime.ToString ( &#8216;m&#8217; ) :<\/strong><br \/>\n0 \tMMMM dd \tAugust 22<br \/>\n<strong>The patterns for DateTime.ToString ( &#8216;r&#8217; ) :<\/strong><br \/>\n0 \tddd, dd MMM yyyy HH&#8217;:&#8217;mm&#8217;:&#8217;ss &#8216;GMT&#8217; \tTue, 22 Aug 2006 06:30:07 GMT<br \/>\n<strong>The patterns for DateTime.ToString ( &#8216;s&#8217; ) :<\/strong><br \/>\n0 \tyyyy&#8217;-&#8216;MM&#8217;-&#8216;dd&#8217;T&#8217;HH&#8217;:&#8217;mm&#8217;:&#8217;ss \t2006-08-22T06:30:07<\/p>\n<p><strong><br \/>\nThe patterns for DateTime.ToString ( &#8216;u&#8217; ) :<\/strong><br \/>\n0 \tyyyy&#8217;-&#8216;MM&#8217;-&#8216;dd HH&#8217;:&#8217;mm&#8217;:&#8217;ss&#8217;Z&#8217; \t2006-08-22 06:30:07Z<br \/>\n<strong>The patterns for DateTime.ToString ( &#8216;U&#8217; ) :<\/strong><br \/>\n0 \tdddd, dd MMMM yyyy HH:mm:ss \tTuesday, 22 August 2006 06:30:07<br \/>\n<strong>The patterns for DateTime.ToString ( &#8216;y&#8217; ) :<\/strong><br \/>\n0 \tyyyy MMMM 2006 August<br \/>\n\/ \tRepresents the date separator defined in the current DateTimeFormatInfo..::.DateSeparator property. This separator is used to differentiate years, months, and days.<br \/>\n&#8221; \tRepresents a quoted string (quotation mark). Displays the literal value of any string between two quotation marks (&#8220;). Your application should precede each quotation mark with an escape character (\\).<br \/>\n&#8216; \tRepresents a quoted string (apostrophe). Displays the literal value of any string between two apostrophe (&#8216;) characters.<br \/>\n%c \tRepresents the result associated with a c custom format specifier, when the custom date and time format string consists solely of that custom format specifier. That is, to use the d, f, F, h, m, s, t, y, z, H, or M custom format specifier by itself, the application should specify %d, %f, %F, %h, %m, %s, %t, %y, %z, %H, or %M. For more information about using a single format specifier, see Using Single Custom Format Specifiers.<\/p>\n<p style=\"text-align: center;\">\n<span style=\"color: #ff0000;\">Building a custom DateTime.ToString Patterns<\/span><\/p>\n<p>The following details the meaning of each pattern character. Not the K and z character.<br \/>\nd \tRepresents the day of the month as a number from 1 through 31. A single-digit day is formatted without a leading zero<br \/>\ndd \tRepresents the day of the month as a number from 01 through 31. A single-digit day is formatted with a leading zero<\/p>\n<p>ddd \tRepresents the abbreviated name of the day of the week (Mon, Tues, Wed etc)<br \/>\ndddd \tRepresents the full name of the day of the week (Monday, Tuesday etc)<br \/>\nh \t12-hour clock hour (e.g. 7)<br \/>\nhh \t12-hour clock, with a leading 0 (e.g. 07)<br \/>\nH \t24-hour clock hour (e.g. 19)<br \/>\nHH \t24-hour clock hour, with a leading 0 (e.g. 19)<br \/>\nm \tMinutes<br \/>\nmm \tMinutes with a leading zero<br \/>\nM \tMonth number<br \/>\nMM \tMonth number with leading zero<br \/>\nMMM \tAbbreviated Month Name (e.g. Dec)<br \/>\nMMMM \tFull month name (e.g. December)<br \/>\ns \tSeconds<br \/>\nss \tSeconds with leading zero<br \/>\nt \tAbbreviated AM \/ PM (e.g. A or P)<br \/>\ntt \tAM \/ PM (e.g. AM or PM<br \/>\ny \tYear, no leading zero (e.g. 2001 would be 1)<br \/>\nyy \tYear, leadin zero (e.g. 2001 would be 01)<br \/>\nyyy \tYear, (e.g. 2001 would be 2001)<br \/>\nyyyy \tYear, (e.g. 2001 would be 2001)<br \/>\nK \tRepresents the time zone information of a date and time value (e.g. +05:00)<br \/>\nz \tWith DateTime values, represents the signed offset of the local operating system&#8217;s time zone from Coordinated Universal Time (UTC), measured in hours. (e.g. +6)<br \/>\nzz \tAs z but with leadin zero (e.g. +06)<br \/>\nzzz \tWith DateTime values, represents the signed offset of the local operating system&#8217;s time zone from UTC, measured in hours and minutes. (e.g. +06:00)<br \/>\nf \tRepresents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value.<br \/>\nff \tRepresents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value.<br \/>\nfff \tRepresents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value.<br \/>\nffff \tRepresents the four most significant digits of the seconds fraction; that is, it represents the ten thousandths of a second in a date and time value. While it is possible to display the ten thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock&#8217;s resolution is approximately 10-15 milliseconds.<br \/>\nfffff \tRepresents the five most significant digits of the seconds fraction; that is, it represents the hundred thousandths of a second in a date and time value. While it is possible to display the hundred thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock&#8217;s resolution is approximately 10-15 milliseconds.<br \/>\nffffff \tRepresents the six most significant digits of the seconds fraction; that is, it represents the millionths of a second in a date and time value. While it is possible to display the millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock&#8217;s resolution is approximately 10-15 milliseconds.<br \/>\nfffffff \tRepresents the seven most significant digits of the seconds fraction; that is, it represents the ten millionths of a second in a date and time value. While it is possible to display the ten millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock&#8217;s resolution is approximately 10-15 milliseconds.<br \/>\nF \tRepresents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. Nothing is displayed if the digit is zero.<br \/>\n: \tRepresents the time separator defined in the current DateTimeFormatInfo..::.TimeSeparator property. This separator is used to differentiate hours, minutes, and seconds.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>All the patterns: 0 MM\/dd\/yyyy 08\/22\/2006 1 dddd, dd MMMM yyyy Tuesday, 22 August 2006 2 dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30 3 dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM 4 dddd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30 5 dddd, dd MMMM yyyy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[110],"tags":[],"_links":{"self":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/102"}],"collection":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102"}],"version-history":[{"count":3,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":173,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions\/173"}],"wp:attachment":[{"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.raytawil.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}