Skip to content


Bug fix: Post date being set to current date. #16

wants to merge 1 commit into from

2 participants


Also, not respecting daylight savings time.


Awesome! We need to implement this in two places ($tweet->add() and $tweet->create_blog_post()) so I'll abstract this to a utility method.

Thanks, I hadn't known about the DST issue.


No prob, thanks for releasing this plugin, maintaining it, and providing support. I know first hand how much work is involved. :)


Uh-oh, this approach doesn't work as currently coded. There is a "Manual" section of time zones that we need to account for. This fix is working for me:

Please confirm, thanks!


Ok, it's working for me and I only have time today to release so off we go. We can always do a 3.0.3 if needed. :)


FYI, I believe this is the relevant bug reported in core:

@bradt bradt referenced this pull request from a commit in bradt/wp-twitter-tools
@alexkingorg alexkingorg attempt to address GMT date issue, props bradt crowdfavorite#16 0dbd327
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 24, 2012
  1. @bradt
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 1 deletion.
  1. +11 −1 classes/aktt_tweet.php
12 classes/aktt_tweet.php
@@ -463,6 +463,15 @@ function sideload_image() {
* @return void
function add() {
+ $gmt_time = self::twdate_to_time($this->date());
+ $gmt_date = date('Y-m-d H:i:s', $gmt_time);
+ // Not using get_option('gmt_offset') because it gets the offset for the
+ // current date/time which doesn't work for timezones with daylight savings time.
+ $datetime = new DateTime( $gmt_date );
+ $datetime->setTimezone(new DateTimeZone(get_option('timezone_string')));
+ $offset_in_secs = $datetime->getOffset();
// Build the post data
$data = apply_filters('aktt_tweet_add', array(
'post_title' => $this->title(),
@@ -470,7 +479,8 @@ function add() {
'post_content' => $this->content(),
'post_status' => 'publish',
'post_type' => AKTT::$post_type,
- 'post_date_gmt' => date('Y-m-d H:i:s', self::twdate_to_time($this->date())),
+ 'post_date_gmt' => date('Y-m-d H:i:s', $gmt_time),
+ 'post_date' => date('Y-m-d H:i:s', $gmt_time + $offset_in_secs),
'guid' => $this->guid(),
// 'tax_input' => $tax_input, // see below...
Something went wrong with that request. Please try again.