How to return correct timezone in PHP

I have the following PHP date function and it returns β€œUTC” as a time zone. I need the time zone for America / New York to change as EST or EDT .

date( 'D, d M Y H:i:s T' );

He returns: Thu, 08 Oct 2015 16:48:00 UTC

I need him to be back Thu, 08 Oct 2015 16:48:00 EDT

Modified.

Here is my complete line of PHP code:

date_default_timezone_set( 'America/New_York' );
echo '<meta http-equiv="last-modified" content="' . date( 'D, d M Y H:i:s T', strtotime( get_the_date() .' ' . get_the_time() ) ) . '" />' . "\n";

This is part of the WordPress plugin, the purpose of which is to insert a meta tag in the header container to reflect the date and time the WP message was last updated.

+4
source share
1 answer

America/New_York, RFC850

DATE_RFC850

RFC850, USENET. PHP - "l, d-M-y H: i: s T", (DATE_RFC850) - ", 14 -05 16:13:03 UTC".

date_default_timezone_set('America/New_York');
$a = strtotime('2015-08-11 16:48:00');
print date(DATE_RFC850, $a);

// output
Tuesday, 11-Aug-15 16:48:00 EDT

php.ini

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
; date.timezone =
+1

Source: https://habr.com/ru/post/1660216/


All Articles