{"id":84,"date":"2016-10-08T20:30:06","date_gmt":"2016-10-08T20:30:06","guid":{"rendered":"http:\/\/uysalyilmaz.com\/wordpress\/?p=84"},"modified":"2016-10-08T20:30:06","modified_gmt":"2016-10-08T20:30:06","slug":"datetime-format","status":"publish","type":"post","link":"http:\/\/uysalyilmaz.com\/index.php\/2016\/10\/08\/datetime-format\/","title":{"rendered":"DateTime format"},"content":{"rendered":"<pre class=\"lang:c# decode:true \">class Program\r\n{\r\n    public static void Main(string[] args)\r\n    {\r\n        DateTime thisDate = DateTime.Now;\r\n        \/\/Standard Time Formatting\r\n \r\n        \/\/Pattern 1: dd\/MM\/yyyy\r\n        Console.WriteLine(\"Pattern 1: Today is in dd\/MM\/yyyy format :\" + thisDate.ToString(\"dd\/MM\/yyyy\"));\/\/18\/09\/2016\r\n \r\n        \/\/Pattern 2: dd-MM-yyyy\r\n        Console.WriteLine(\"Pattern 2: Today is in dd-MM-yyyy format :\" + thisDate.ToString(\"dd-MM-yyyy\"));\/\/18-09-2016\r\n \r\n        \/\/Pattern 3: yyyy-MM-dd\r\n        Console.WriteLine(\"Pattern 3: Today is in yyyy-MM-dd format :\" + thisDate.ToString(\"yyyy-MM-dd\"));\/\/2016-09-18\r\n \r\n        \/\/Pattern 4: dd MMMM yyyy\r\n        Console.WriteLine(\"Pattern 4: Today is in dd MMMM yyyy format :\" + thisDate.ToString(\"dd MMMM yyyy\"));\/\/18 September 2016\r\n \r\n        \/\/Pattern 5: short Time {0:t}\r\n        Console.WriteLine(\"Pattern 5: Time in {0:t} format :\" + String.Format(\"{0:t}\", thisDate));\/\/10:26 PM\r\n \r\n        \/\/Pattern 6: {0:d} shortdate\r\n        Console.WriteLine(\"Pattern 6: Today is in {0:d} format :\" + String.Format(\"{0:d}\", thisDate));\/\/9\/18\/2016\r\n \r\n        \/\/Pattern 7: {0:T} long time\r\n        Console.WriteLine(\"Pattern 7: Today is in {0:T} format :\" + String.Format(\"{0:T}\", thisDate));\/\/10:26:35PM\r\n \r\n        \/\/Pattern 8: {0:D} Long Date\r\n        Console.WriteLine(\"Pattern 8: Today is in {0:D} format :\" + String.Format(\"{0:D}\", thisDate));\/\/September 18, 2016\r\n \r\n        \/\/Pattern 9: {0:f} Longdate &amp; short time\r\n        Console.WriteLine(\"Pattern 9: Today is in {0:f} format :\" + String.Format(\"{0:f}\", thisDate));\/\/September 18, 2016 10:26 PM\r\n \r\n        \/\/Pattern 10: {0:F} Full date Time\r\n        Console.WriteLine(\"Pattern 10: Today is in {0:F} format :\" + String.Format(\"{0:F}\", thisDate));\/\/September 18, 2016 10:26:35PM\r\n \r\n        \/\/Pattern 11: {0:g} Shortdate &amp; Short Time\r\n        Console.WriteLine(\"Pattern 11: Today is in {0:g} format :\" + String.Format(\"{0:g}\", thisDate));\/\/9\/18\/2016 22:26 PM\r\n \r\n        \/\/Pattern 12: {0:G} Shortdate &amp; Long Time\r\n        Console.WriteLine(\"Pattern 12: Today is in {0:G} format :\" + String.Format(\"{0:G}\", thisDate));\/\/9\/18\/2016 22:26:35 PM\r\n \r\n        \/\/Pattern 13: {0:m} Month Day\r\n        Console.WriteLine(\"Pattern 13: Today is in {0:m} format :\" + String.Format(\"{0:m}\", thisDate));\/\/September 18\r\n \r\n        \/\/Pattern 14: {0:y} Year Month\r\n        Console.WriteLine(\"Pattern 14: Today is in {0:y} format :\" + String.Format(\"{0:y}\", thisDate));\/\/September,2016\r\n \r\n        \/\/Pattern 15: {0:r}\r\n        Console.WriteLine(\"Pattern 15:Today is in {0:r} format :\" + String.Format(\"{0:r}\", thisDate));\/\/18 Sep 2016 22:26:35 GMT\r\n \r\n        \/\/Pattern 16: Time {0:s} sortable datetime\r\n        Console.WriteLine(\"Pattern 16:Today is in {0:s} format :\" + String.Format(\"{0:s}\", thisDate));\/\/2016-09-18T22:26:35\r\n \r\n        \/\/Pattern 17: Time {0:u} Univerasal Sortdate time\r\n        Console.WriteLine(\"Pattern 17: Today is in {0:u} format :\" + String.Format(\"{0:u}\", thisDate));\/\/2016-09-18 22:26:35Z\r\n        \r\n        \/\/Custom Datetime Formatting\r\n \r\n        \/\/ Pattern 18: month\/day numbers without\/with leading zeroes\r\n        Console.WriteLine(\"Pattern 18: Today is in {0:M\/d\/yyyy} format:\" + String.Format(\"{0:M\/d\/yyyy}\", thisDate)); \/\/9\/18\/2016          \r\n        Console.WriteLine(\"Pattern 18: Today is in {0:MM\/dd\/yyyy} format:\" + String.Format(\"{0:MM\/dd\/yyyy}\", thisDate));\/\/09\/18\/2016\r\n \r\n        \/\/ Pattern 19: day\/month names\r\n        Console.WriteLine(\"Pattern 19: Today is in {0:ddd, MMM d, yyyy} format:\" + String.Format(\"{0:ddd, MMM d, yyyy}\", thisDate));\/\/Sun,Sep 18, 2016\r\n        Console.WriteLine(\"Pattern 19: Today is in {0:dddd, MMMM d, yyyy} format:\" + String.Format(\"{0:dddd, MMMM d, yyyy}\", thisDate));\/\/Sunday,September 18, 2016\r\n \r\n       \/\/ Pattern 20: two\/four digit year\r\n        Console.WriteLine(\"Pattern 20: Today is in {0:MM\/dd\/yy} format:\" + String.Format(\"{0:MM\/dd\/yy}\", thisDate));\/\/09\/18\/16\r\n        Console.WriteLine(\"Pattern 20: Today is in {0:MM\/dd\/yyyy} format:\" + String.Format(\"{0:MM\/dd\/yyyy}\", thisDate));\/\/09\/18\/2016\r\n \r\n        \/\/ Pattern 21: {0:y yy yyy yyyy}\r\n        Console.WriteLine(\"Pattern 21: year {0:y yy yyy yyyy} format:\" + String.Format(\"{0:y yy yyy yyyy}\", thisDate));\/\/16 16 2016 2016\r\n \r\n        \/\/ Pattern 22: {0:M MM MMM MMMM}\r\n        Console.WriteLine(\"Pattern 22: Month {0:M MM MMM MMMM} format:\" + String.Format(\"{0:M MM MMM MMMM}\", thisDate));\/\/9 09 Sep September\r\n \r\n        \/\/ Pattern 23: {0:d dd ddd dddd}\r\n        Console.WriteLine(\"Pattern 23: Day {0:d dd ddd dddd} format:\" + String.Format(\"{0:d dd ddd dddd}\", thisDate));\/\/18 18 Sun Sunday\r\n \r\n        \/\/ Pattern 24: {0:h hh H HH}\r\n        Console.WriteLine(\"Pattern 24: Hour {0:h hh H HH} format:\" + String.Format(\"{0:h hh H HH}\", thisDate));\/\/10 10 22 22\r\n \r\n        \/\/ Pattern 25: {0:m mm}\r\n        Console.WriteLine(\"Pattern 25: Minute {0:m mm} format:\" + String.Format(\"{0:m mm}\", thisDate));\/\/26 26\r\n \r\n        \/\/ Pattern 26: {0:s ss}\r\n        Console.WriteLine(\"Pattern 26: Sec {0:s ss} format:\" + String.Format(\"{0:s ss}\", thisDate));\/\/35 35\r\n \r\n        \/\/ Pattern 27: {0:f ff fff ffff}\r\n        Console.WriteLine(\"Pattern 27: Sec fraction {0:f ff fff ffff} format:\" + String.Format(\"{0:f ff fff ffff}\", thisDate));\/\/9 94 946 9465\r\n \r\n        \/\/ Pattern 28: {0:h hh H HH}\"\r\n        Console.WriteLine(\"Pattern 28: Sec {0:F FF FFF FFFF} format:\" + String.Format(\"{0:F FF FFF FFFF}\", thisDate));\/\/9 94 946 9465\r\n \r\n        \/\/ Pattern 29: {0:t tt} \r\n        Console.WriteLine(\"Pattern 29: AM or PM  {0:t tt} format:\" + String.Format(\"{0:t tt}\", thisDate)); \/\/ P PM\r\n \r\n        \/\/ Pattern 30: Timezone {0:z zz zzz}\r\n        Console.WriteLine(\"Pattern 30: timeZone {0:z zz zzz} format:\" + String.Format(\"{0:z zz zzz}\", thisDate)); \/\/ -4 -04 -04:00\r\n    }\r\n}<\/pre>\n<p><a href=\"http:\/\/www.csharpstar.com\/csharp-string-format-datetime\/\" target=\"_blank\">Kaynak<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>class Program { public static void Main(string[] args) { DateTime thisDate = DateTime.Now; \/\/Standard Time Formatting \/\/Pattern 1: dd\/MM\/yyyy Console.WriteLine(&#8220;Pattern 1: Today is in dd\/MM\/yyyy format :&#8221; + thisDate.ToString(&#8220;dd\/MM\/yyyy&#8221;));\/\/18\/09\/2016 \/\/Pattern 2: dd-MM-yyyy Console.WriteLine(&#8220;Pattern 2: Today is in dd-MM-yyyy format :&#8221; + thisDate.ToString(&#8220;dd-MM-yyyy&#8221;));\/\/18-09-2016 \/\/Pattern 3: yyyy-MM-dd Console.WriteLine(&#8220;Pattern 3: Today is in yyyy-MM-dd format :&#8221; + thisDate.ToString(&#8220;yyyy-MM-dd&#8221;));\/\/2016-09-18 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[33],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-asp-net-c","tag-datetime-format"],"_links":{"self":[{"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":1,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":85,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/posts\/84\/revisions\/85"}],"wp:attachment":[{"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/uysalyilmaz.com\/index.php\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}