{"id":2097,"date":"2017-02-01T11:48:29","date_gmt":"2017-02-01T11:48:29","guid":{"rendered":"http:\/\/galhano.com\/blog\/?p=2097"},"modified":"2017-02-01T11:49:11","modified_gmt":"2017-02-01T11:49:11","slug":"mysql-date_format","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=2097","title":{"rendered":"MySQL DATE_FORMAT"},"content":{"rendered":"<p>DATE_FORMAT(date,format)<\/p>\n<p>[text]<br \/>\n%a\u00a0\u00a0 \u00a0Abbreviated weekday name (Sun-Sat)<br \/>\n%b\u00a0\u00a0 \u00a0Abbreviated month name (Jan-Dec)<br \/>\n%c\u00a0\u00a0 \u00a0Month, numeric (0-12)<br \/>\n%D\u00a0\u00a0 \u00a0Day of month with English suffix (0th, 1st, 2nd, 3rd, ?)<br \/>\n%d\u00a0\u00a0 \u00a0Day of month, numeric (00-31)<br \/>\n%e\u00a0\u00a0 \u00a0Day of month, numeric (0-31)<br \/>\n%f\u00a0\u00a0 \u00a0Microseconds (000000-999999)<br \/>\n%H\u00a0\u00a0 \u00a0Hour (00-23)<br \/>\n%h\u00a0\u00a0 \u00a0Hour (01-12)<br \/>\n%I\u00a0\u00a0 \u00a0Hour (01-12)<br \/>\n%i\u00a0\u00a0 \u00a0Minutes, numeric (00-59)<br \/>\n%j\u00a0\u00a0 \u00a0Day of year (001-366)<br \/>\n%k\u00a0\u00a0 \u00a0Hour (0-23)<br \/>\n%l\u00a0\u00a0 \u00a0Hour (1-12)<br \/>\n%M\u00a0\u00a0 \u00a0Month name (January-December)<br \/>\n%m\u00a0\u00a0 \u00a0Month, numeric (00-12)<br \/>\n%p\u00a0\u00a0 \u00a0AM or PM<br \/>\n%r\u00a0\u00a0 \u00a0Time, 12-hour (hh:mm:ss followed by AM or PM)<br \/>\n%S\u00a0\u00a0 \u00a0Seconds (00-59)<br \/>\n%s\u00a0\u00a0 \u00a0Seconds (00-59)<br \/>\n%T\u00a0\u00a0 \u00a0Time, 24-hour (hh:mm:ss)<br \/>\n%U\u00a0\u00a0 \u00a0Week (00-53) where Sunday is the first day of week<br \/>\n%u\u00a0\u00a0 \u00a0Week (00-53) where Monday is the first day of week<br \/>\n%V\u00a0\u00a0 \u00a0Week (01-53) where Sunday is the first day of week, used with %X<br \/>\n%v\u00a0\u00a0 \u00a0Week (01-53) where Monday is the first day of week, used with %x<br \/>\n%W\u00a0\u00a0 \u00a0Weekday name (Sunday-Saturday)<br \/>\n%w\u00a0\u00a0 \u00a0Day of the week (0=Sunday, 6=Saturday)<br \/>\n%X\u00a0\u00a0 \u00a0Year for the week where Sunday is the first day of week, four digits, used with %V<br \/>\n%x\u00a0\u00a0 \u00a0Year for the week where Monday is the first day of week, four digits, used with %v<br \/>\n%Y\u00a0\u00a0 \u00a0Year, numeric, four digits<br \/>\n%y\u00a0\u00a0 \u00a0Year, numeric, two digits<br \/>\n[\/text]<\/p>\n<p>The following script uses the DATE_FORMAT() function to display different formats. We will use the NOW() function to get the current date\/time:<\/p>\n<p>DATE_FORMAT(NOW(),&#8217;%b %d %Y %h:%i %p&#8217;)<br \/>\nDATE_FORMAT(NOW(),&#8217;%m-%d-%Y&#8217;)<br \/>\nDATE_FORMAT(NOW(),&#8217;%d %b %y&#8217;)<br \/>\nDATE_FORMAT(NOW(),&#8217;%d %b %Y %T:%f&#8217;)<\/p>\n<p>The result would look something like this:<\/p>\n<p>Nov 04 2014 11:45 PM<br \/>\n11-04-2014<br \/>\n04 Nov 14<br \/>\n04 Nov 2014 11:45:34:243<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DATE_FORMAT(date,format) [text] %a\u00a0\u00a0 \u00a0Abbreviated weekday name (Sun-Sat) %b\u00a0\u00a0 \u00a0Abbreviated month name (Jan-Dec) %c\u00a0\u00a0 \u00a0Month, numeric (0-12) %D\u00a0\u00a0 \u00a0Day of month with English suffix (0th, 1st, 2nd, 3rd, ?) %d\u00a0\u00a0 \u00a0Day of month, numeric (00-31) %e\u00a0\u00a0 \u00a0Day of month, numeric (0-31) %f\u00a0\u00a0 \u00a0Microseconds (000000-999999) %H\u00a0\u00a0 \u00a0Hour (00-23) %h\u00a0\u00a0 \u00a0Hour (01-12) %I\u00a0\u00a0 \u00a0Hour (01-12) %i\u00a0\u00a0 \u00a0Minutes, numeric [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,40],"tags":[],"class_list":["post-2097","post","type-post","status-publish","format-standard","hentry","category-code-snippets","category-sql","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2097","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2097"}],"version-history":[{"count":2,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2097\/revisions"}],"predecessor-version":[{"id":2099,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2097\/revisions\/2099"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2097"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}