{"id":786,"date":"2013-06-29T01:06:59","date_gmt":"2013-06-28T18:06:59","guid":{"rendered":"http:\/\/blog.kusumoto.co\/?p=786"},"modified":"2013-06-29T01:12:29","modified_gmt":"2013-06-28T18:12:29","slug":"php-convert-sql-date-yyyy-mm-dd-type-to-thai-message","status":"publish","type":"post","link":"https:\/\/oldblog.kusumotolab.com\/?p=786","title":{"rendered":"[PHP] Convert SQL &#8216;date [YYYY-MM-DD]&#8217; data type to Thai Message"},"content":{"rendered":"<p>\u0e17\u0e35\u0e48\u0e08\u0e23\u0e34\u0e07\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e19\u0e35\u0e49\u0e40\u0e02\u0e35\u0e22\u0e19\u0e02\u0e36\u0e49\u0e19\u0e21\u0e32\u0e19\u0e32\u0e19\u0e41\u0e2b\u0e25\u0e30 \u0e41\u0e25\u0e30\u0e17\u0e35\u0e48\u0e40\u0e2d\u0e32\u0e1b\u0e25\u0e48\u0e2d\u0e22\u0e40\u0e1e\u0e23\u0e32\u0e30\u0e21\u0e31\u0e19\u0e19\u0e48\u0e32\u0e08\u0e30\u0e21\u0e35\u0e1b\u0e23\u0e30\u0e42\u0e22\u0e0a\u0e19\u0e4c\u0e19\u0e30 \u0e2d\u0e35\u0e01\u0e2d\u0e22\u0e48\u0e32\u0e07 \u0e23\u0e2d\u0e07\u0e23\u0e31\u0e1a PHP 5.3 \u0e02\u0e31\u0e49\u0e19\u0e44\u0e1b\u0e2d\u0e35\u0e01\u0e14\u0e49\u0e27\u0e22<\/p>\n<pre lang=\"php\">\r\n\/*\r\nDate Converter Function\r\nby Kusumoto\r\n*\/\r\n\r\nfunction convertdate($date) {\r\n\/\/\u0e41\u0e22\u0e01\u0e15\u0e31\u0e27\u0e40\u0e25\u0e02\u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07\u0e2b\u0e21\u0e32\u0e22 -\r\n\t$day = substr($date, 8, 2);\r\n\t$year = substr($date, 0, 4);\r\n\t$month = substr($date, 5, 2);\r\n\/\/\u0e17\u0e33\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Array \u0e17\u0e35\u0e48\u0e40\u0e01\u0e47\u0e1a\u0e40\u0e14\u0e37\u0e2d\u0e19\u0e15\u0e48\u0e32\u0e07\u0e46\r\n\t$thai_month_arr=array(\r\n\t\"0\"=>\"\",\r\n\t\"01\"=>\"\u0e21\u0e01\u0e23\u0e32\u0e04\u0e21\",\r\n\t\"02\"=>\"\u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c\",\r\n\t\"03\"=>\"\u0e21\u0e35\u0e19\u0e32\u0e04\u0e21\",\r\n\t\"04\"=>\"\u0e40\u0e21\u0e29\u0e32\u0e22\u0e19\",\r\n\t\"05\"=>\"\u0e1e\u0e24\u0e29\u0e20\u0e32\u0e04\u0e21\",\r\n\t\"06\"=>\"\u0e21\u0e34\u0e16\u0e38\u0e19\u0e32\u0e22\u0e19\",\t\r\n\t\"07\"=>\"\u0e01\u0e23\u0e01\u0e0e\u0e32\u0e04\u0e21\",\r\n\t\"08\"=>\"\u0e2a\u0e34\u0e07\u0e2b\u0e32\u0e04\u0e21\",\r\n\t\"09\"=>\"\u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19\",\r\n\t\"10\"=>\"\u0e15\u0e38\u0e25\u0e32\u0e04\u0e21\",\r\n\t\"11\"=>\"\u0e1e\u0e24\u0e28\u0e08\u0e34\u0e01\u0e32\u0e22\u0e19\",\r\n\t\"12\"=>\"\u0e18\u0e31\u0e19\u0e27\u0e32\u0e04\u0e21\"\t\t\t\t\t\r\n);\r\n\/\/\u0e17\u0e33\u0e01\u0e32\u0e23\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e40\u0e14\u0e37\u0e2d\u0e19\u0e15\u0e32\u0e21\u0e15\u0e31\u0e27\u0e40\u0e25\u0e02\u0e17\u0e35\u0e48\u0e23\u0e30\u0e1a\u0e38\r\n\t$month_final = $thai_month_arr[($month)];\r\n\/\/\u0e17\u0e33\u0e01\u0e32\u0e23\u0e23\u0e27\u0e21 \u0e27\u0e31\u0e19 \u0e40\u0e14\u0e37\u0e2d\u0e19 \u0e1b\u0e35 \u0e40\u0e02\u0e49\u0e32\u0e40\u0e1b\u0e47\u0e19\u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19 \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e15\u0e23\u0e35\u0e22\u0e21\u0e2a\u0e48\u0e07\u0e04\u0e48\u0e32\u0e2d\u0e2d\u0e01\u0e19\u0e2d\u0e01\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\r\n\t$date = $day . ' ' . $month_final . ' ' . $year; \r\n\/\/\u0e2a\u0e48\u0e07\u0e04\u0e48\u0e32\u0e2d\u0e2d\u0e01\u0e19\u0e2d\u0e01\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19 \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e19\u0e33\u0e44\u0e1b\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e15\u0e48\u0e2d\r\n\treturn $date;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0e17\u0e35\u0e48\u0e08\u0e23\u0e34\u0e07\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e19\u0e35\u0e49\u0e40\u0e02\u0e35\u0e22\u0e19\u0e02\u0e36\u0e49\u0e19\u0e21\u0e32\u0e19\u0e32\u0e19\u0e41\u0e2b\u0e25\u0e30 \u0e41\u0e25\u0e30\u0e17\u0e35\u0e48\u0e40\u0e2d\u0e32\u0e1b\u0e25\u0e48\u0e2d\u0e22\u0e40\u0e1e\u0e23\u0e32\u0e30\u0e21\u0e31\u0e19\u0e19\u0e48\u0e32\u0e08\u0e30\u0e21\u0e35\u0e1b\u0e23\u0e30\u0e42\u0e22\u0e0a\u0e19\u0e4c\u0e19\u0e30 \u0e2d\u0e35\u0e01\u0e2d\u0e22\u0e48\u0e32\u0e07 \u0e23\u0e2d\u0e07\u0e23\u0e31\u0e1a PHP 5.3 \u0e02\u0e31\u0e49\u0e19\u0e44\u0e1b\u0e2d\u0e35\u0e01\u0e14\u0e49\u0e27\u0e22 \/* Date Converter Function by Kusumoto *\/ function convertdate($date) { \/\/\u0e41\u0e22\u0e01\u0e15\u0e31\u0e27\u0e40\u0e25\u0e02\u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e40\u0e04\u0e23\u0e37\u0e48\u0e2d\u0e07\u0e2b\u0e21\u0e32\u0e22 &#8211; $day = substr($date, 8, 2); $year = substr($date, 0, 4); $month = substr($date, 5, 2); \/\/\u0e17\u0e33\u0e01\u0e32\u0e23\u0e2a\u0e23\u0e49\u0e32\u0e07 Array \u0e17\u0e35\u0e48\u0e40\u0e01\u0e47\u0e1a\u0e40\u0e14\u0e37\u0e2d\u0e19\u0e15\u0e48\u0e32\u0e07\u0e46 $thai_month_arr=array( &#8220;0&#8221;=>&#8221;&#8221;, &#8220;01&#8221;=>&#8221;\u0e21\u0e01\u0e23\u0e32\u0e04\u0e21&#8221;, &#8220;02&#8221;=>&#8221;\u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c&#8221;, &#8220;03&#8221;=>&#8221;\u0e21\u0e35\u0e19\u0e32\u0e04\u0e21&#8221;, &#8220;04&#8221;=>&#8221;\u0e40\u0e21\u0e29\u0e32\u0e22\u0e19&#8221;, &#8220;05&#8221;=>&#8221;\u0e1e\u0e24\u0e29\u0e20\u0e32\u0e04\u0e21&#8221;, &#8220;06&#8221;=>&#8221;\u0e21\u0e34\u0e16\u0e38\u0e19\u0e32\u0e22\u0e19&#8221;, &#8220;07&#8221;=>&#8221;\u0e01\u0e23\u0e01\u0e0e\u0e32\u0e04\u0e21&#8221;, &#8220;08&#8221;=>&#8221;\u0e2a\u0e34\u0e07\u0e2b\u0e32\u0e04\u0e21&#8221;, &#8220;09&#8221;=>&#8221;\u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19&#8221;, &#8220;10&#8221;=>&#8221;\u0e15\u0e38\u0e25\u0e32\u0e04\u0e21&#8221;, &#8220;11&#8221;=>&#8221;\u0e1e\u0e24\u0e28\u0e08\u0e34\u0e01\u0e32\u0e22\u0e19&#8221;, &#8220;12&#8221;=>&#8221;\u0e18\u0e31\u0e19\u0e27\u0e32\u0e04\u0e21&#8221; ); \/\/\u0e17\u0e33\u0e01\u0e32\u0e23\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e40\u0e14\u0e37\u0e2d\u0e19\u0e15\u0e32\u0e21\u0e15\u0e31\u0e27\u0e40\u0e25\u0e02\u0e17\u0e35\u0e48\u0e23\u0e30\u0e1a\u0e38 $month_final = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[14,13],"tags":[],"class_list":["post-786","post","type-post","status-publish","format-standard","hentry","category-mysql","category-php"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3OMEb-cG","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=786"}],"version-history":[{"count":6,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/786\/revisions"}],"predecessor-version":[{"id":792,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/786\/revisions\/792"}],"wp:attachment":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}