get_the_date() return always UTC+0 [duplicate]

date_default_timezone_set can alter the output of a new DateTime. Not sure how it will affect get_the_time. $date = new DateTime( get_the_time(‘c’) ); $date->setTimezone(new DateTimeZone(‘Europe/Warsaw’)); echo $date->format(‘c’); $date = new DateTime(); echo $date->format(‘c’); // 2015-12-18T18:21:31+00:00 $date->setTimezone(new DateTimeZone(‘Europe/Warsaw’)); echo $date->format(‘c’); // 2015-12-18T19:21:31+01:00 date_default_timezone_set(‘Europe/Warsaw’); $date = new DateTime(); echo $date->format(‘c’); // 2015-12-18T19:21:31+01:00

XML RPC post produces immediate revision with odd post_date_gmt

Alright. I think I cracked it. <dateTime.iso8601>20140111T20:39:15</dateTime.iso8601> Should be: <dateTime.iso8601>20140111T20:39:15Z</dateTime.iso8601> Looks like the toolkit I was using didn’t quite implement iso8601 perfectly (or wordpress isn’t – not sure). I’m using Node WordPress and tracked down that it uses the module Node XML RPC to actually send the XML RPC. This seems to be where the … Read more

How to get Unix Local Time?

Please use DateTime::getTimestamp() that returns unix timestamp. If you want to format the date according to your time zone then you try this. $datetime = new DateTime(“now”, new DateTimeZone(‘America/New York’)); echo $datetime ->format(‘m/d/Y, H:i:s’);

Difference between date and date_gmt

The database is correct in this case. comment_date is the datetime of your WordPress timezone setting and comment_date_gmt is the same datetime, but converted to Greenwich Mean Time (GMT). GMT is the timezone all other timezones are offset from while UTC is the time standard. In most practical applications they’re interchangeable. The problem you’re probably … Read more

WordPress detects the wrong timezone

Turns out there was a previous attempt to fix the timezone: date_default_timezone_set(‘America/Sao_Paulo’); was called on the init hook. When later the correct UTC time, local time and timezone were properly set on the server, this caused a conflict. Removing this solved the issue.