WordPress returns a wrong date

As mmm said, wp stores all dates&times in gmt, but will show times as per the setting timezone. So you can cgange the timezone without the history needing to be updated.
I prefer to use the php datetime when working with time. Gives better control and flexibility, eg if you want to show events in different users timezones, let the system deal with daylight saving etc.

To Fetch the wp timezone and create tz object, then use

$tzs = get_option('timezone_string');
$tzobj = timezone_open($tzs); 

To create datetime object for ‘now’ in a particular timezone

$now = date_create('now',$tzobj );

to format dates & times, use any format accepted by date()

echo date_format($now, 'Y-m-d H:i:s');

Leave a Comment