{"id":509,"date":"2012-03-23T10:05:08","date_gmt":"2012-03-23T08:05:08","guid":{"rendered":"https:\/\/polyetilen.lt\/?p=509"},"modified":"2023-05-02T09:26:23","modified_gmt":"2023-05-02T06:26:23","slug":"local-date-format-in-php-or-mysql","status":"publish","type":"post","link":"https:\/\/polyetilen.lt\/en\/local-date-format-in-php-or-mysql","title":{"rendered":"Local date format in PHP or MySQL"},"content":{"rendered":"<p>If locale is installed on the server then with PHP:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?\r\n\/\/time zone from here http:\/\/php.net\/manual\/en\/timezones.php\r\ndate_default_timezone_set('America\/Panama');\r\n\/\/set locale\r\nsetlocale(LC_TIME, 'en_US.UTF8');\r\n\/\/reverse convert Unix timestamp to local date\r\necho strftime('%A, %d %B %Y %Z %x', time()); \/\/Friday, 23 March 2012 EST 03\/23\/2012\r\n\r\n\/\/for function strtotime date should be GNU format http:\/\/www.gnu.org\/software\/shishi\/manual\/html_node\/Date-input-formats.html\r\n\/\/reverse convert the local date to the Unix timestamp\r\necho strtotime('Friday, 23 March 2012'); \/\/1332478800\r\n<\/pre>\n<p>For MySQL local date:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSET lc_time_names = 'en_US'; -- set locale\r\nSET time_zone = '-5:00'; -- set time zone http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/time-zone-support.html\r\nSELECT DATE_FORMAT(NOW(),'%e %M, %W'); -- 23 March, Friday\r\nSELECT DATE_FORMAT(FROM_UNIXTIME(1242733660),'%e %M, %W'); -- 19 May, Tuesday\r\nSELECT DATE_FORMAT(NOW(),'%M %D, %Y, %W, %l:%i %p'); -- March 23rd, 2012, Friday, 4:36 AM\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If locale is installed on the server then with PHP: &lt;? \/\/time zone from here http:\/\/php.net\/manual\/en\/timezones.php date_default_timezone_set('America\/Panama'); \/\/set locale setlocale(LC_TIME, 'en_US.UTF8'); \/\/reverse convert Unix timestamp to local date echo strftime('%A, %d %B %Y %Z %x', &hellip; <a href=\"https:\/\/polyetilen.lt\/en\/local-date-format-in-php-or-mysql\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"http:\/\/polyetilen.lt\/?p=270","footnotes":""},"categories":[8],"tags":[75,104,32,34],"class_list":["post-509","post","type-post","status-publish","format-standard","hentry","category-programavimas","tag-data","tag-formatas","tag-mysql","tag-php","en-US"],"_links":{"self":[{"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/posts\/509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/comments?post=509"}],"version-history":[{"count":1,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/posts\/509\/revisions"}],"predecessor-version":[{"id":510,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/posts\/509\/revisions\/510"}],"wp:attachment":[{"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/media?parent=509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/categories?post=509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/polyetilen.lt\/wp-json\/wp\/v2\/tags?post=509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}