{"id":970,"date":"2010-06-15T20:43:42","date_gmt":"2010-06-15T14:43:42","guid":{"rendered":"http:\/\/aasims.wordpress.com\/?p=970"},"modified":"2025-04-07T20:54:01","modified_gmt":"2025-04-07T20:54:01","slug":"date-formatting-in-c","status":"publish","type":"post","link":"https:\/\/aasimnaseem.com\/blog\/date-formatting-in-c\/","title":{"rendered":"Date Formatting in C#"},"content":{"rendered":"<p>Hello all.<\/p>\n<p>hope doing well &#8230;<\/p>\n<p>here is another tip related to C# programming &#8230;. i found it useful so sharing with you people &#8230; \u00a0 this is how you can format date in different format in asp.net \/ C#<\/p>\n<p>the usage is as follows<\/p>\n<blockquote><p>&lt;%= String.Format(&#8220;{<em>specifier<\/em>}&#8221;, DateTime.Now) %&gt;<\/p><\/blockquote>\n<p>where the possible specifiers are given below.<\/p>\n<table>\n<tbody>\n<tr>\n<th>Specifier<\/th>\n<th>Description<\/th>\n<th>Output<\/th>\n<\/tr>\n<tr>\n<td>d<\/td>\n<td>Short Date<\/td>\n<td>15\/05\/2010<\/td>\n<\/tr>\n<tr>\n<td>D<\/td>\n<td>Long Date<\/td>\n<td>15 June 2010<\/td>\n<\/tr>\n<tr>\n<td>t<\/td>\n<td>Short Time<\/td>\n<td>21:08<\/td>\n<\/tr>\n<tr>\n<td>T<\/td>\n<td>Long Time<\/td>\n<td>21:08:59<\/td>\n<\/tr>\n<tr>\n<td>f<\/td>\n<td>Full date and time<\/td>\n<td>15 June 2010 21:08<\/td>\n<\/tr>\n<tr>\n<td>F<\/td>\n<td>Full date and time (long)<\/td>\n<td>15 June 2010 21:08:59<\/td>\n<\/tr>\n<tr>\n<td>g<\/td>\n<td>Default date and time<\/td>\n<td>15\/06\/2010 21:08<\/td>\n<\/tr>\n<tr>\n<td>G<\/td>\n<td>Default date and time (long)<\/td>\n<td>15\/06\/2010 21:08:59<\/td>\n<\/tr>\n<tr>\n<td>M<\/td>\n<td>Day \/ Month<\/td>\n<td>15 June<\/td>\n<\/tr>\n<tr>\n<td>r<\/td>\n<td>RFC1123 date<\/td>\n<td>Tue, 15 June 2010 21:08:59 GMT<\/td>\n<\/tr>\n<tr>\n<td>s<\/td>\n<td>Sortable date\/time<\/td>\n<td>2010-06-15 21:08:59<\/td>\n<\/tr>\n<tr>\n<td>u<\/td>\n<td>Universal time, local timezone<\/td>\n<td>2010-06-15 21:08:59Z<\/td>\n<\/tr>\n<tr>\n<td>Y<\/td>\n<td>Month \/ Year<\/td>\n<td>June 2010<\/td>\n<\/tr>\n<tr>\n<td>dd<\/td>\n<td>Day<\/td>\n<td>15<\/td>\n<\/tr>\n<tr>\n<td>ddd<\/td>\n<td>Short Day Name<\/td>\n<td>Sun<\/td>\n<\/tr>\n<tr>\n<td>dddd<\/td>\n<td>Full Day Name<\/td>\n<td>Sunday<\/td>\n<\/tr>\n<tr>\n<td>hh<\/td>\n<td>2 digit hour<\/td>\n<td>09<\/td>\n<\/tr>\n<tr>\n<td>HH<\/td>\n<td>2 digit hour (24 hour)<\/td>\n<td>21<\/td>\n<\/tr>\n<tr>\n<td>mm<\/td>\n<td>2 digit minute<\/td>\n<td>08<\/td>\n<\/tr>\n<tr>\n<td>MM<\/td>\n<td>Month<\/td>\n<td>04<\/td>\n<\/tr>\n<tr>\n<td>MMM<\/td>\n<td>Short Month name<\/td>\n<td>Jun<\/td>\n<\/tr>\n<tr>\n<td>MMMM<\/td>\n<td>Month name<\/td>\n<td>June<\/td>\n<\/tr>\n<tr>\n<td>ss<\/td>\n<td>seconds<\/td>\n<td>59<\/td>\n<\/tr>\n<tr>\n<td>tt<\/td>\n<td>AM\/PM<\/td>\n<td>PM<\/td>\n<\/tr>\n<tr>\n<td>yy<\/td>\n<td>2 digit year<\/td>\n<td>07<\/td>\n<\/tr>\n<tr>\n<td>yyyy<\/td>\n<td>4 digit year<\/td>\n<td>2010<\/td>\n<\/tr>\n<tr>\n<td>:<\/td>\n<td>seperator, e.g. {0:hh:mm:ss}<\/td>\n<td>09:08:59<\/td>\n<\/tr>\n<tr>\n<td>\/<\/td>\n<td>seperator, e.g. {0:dd\/MM\/yyyy}<\/td>\n<td>15\/06\/2010<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>happy development \ud83d\ude42<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/s04.flagcounter.com\/count\/BgW\/bg=FFFFFF\/txt=000000\/border=FFFFFF\/columns=8\/maxflags=200\/viewers=0\/labels=1\/pageviews=1\/\" border=\"0\" alt=\"free counters\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello all. hope doing well &#8230; here is another tip related to C# programming &#8230;. i found it useful so sharing with you people &#8230; \u00a0 this is how you can format date in different format in asp.net \/ C# the usage is as follows &lt;%= String.Format(&#8220;{specifier}&#8221;, DateTime.Now) %&gt; where&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[28,166,246,308,309],"class_list":["post-970","post","type-post","status-publish","format-standard","hentry","category-random","tag-net","tag-asp-net","tag-c","tag-date-formatting","tag-date-formatting-in-c"],"_links":{"self":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/comments?post=970"}],"version-history":[{"count":1,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/970\/revisions"}],"predecessor-version":[{"id":4499,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/posts\/970\/revisions\/4499"}],"wp:attachment":[{"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/media?parent=970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/categories?post=970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aasimnaseem.com\/blog\/wp-json\/wp\/v2\/tags?post=970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}