Viewing 1 replies (of 1 total)
  • Hello graymerica,

    nice find. I had the same problem. But the above wasn’t working.

    I had to use a more difficult way how to obtain current time respecting the WP time zone. I also had to switch the timezone from UTC-5 to “New York”, date_default_timezone_set wasn’t working with just UTC-5.

    function dateValid($date,$type){
      $date = mysql2date('U',$date,false);
    
      /// Addition
      $tz = get_option('timezone_string');
      date_default_timezone_set( $tz );
      $datetime = new DateTime( date('Y-m-d H:i:s') );
      $offset = $datetime->getOffset();
      $time = $datetime->format('U');
      $time = (int)$time + (int)$offset;
      //echo '<!-- COMMENT: '.$date.' server: '.$time.' -->';
      date_default_timezone_set('UTC');
      //echo ($date-$time);
      /// End of addition
    
      $editablecomments = get_option('editable-comments');
      if($type == 'edit')
        $minutes = $editablecomments['minutes'];
      if($type == 'delete')
        $minutes = $editablecomments['deleteminutes'];
      ///  Modification
      //if($date >= time() - $minutes * 60)
      if($date >= $time - $minutes * 60)
      ///
        return true;
    
      return false;
    }

    Other than that, the “Comment updated” message is not showing up in the Thesis. And it also could be more secure. If you post a comment, everybody from the same IP will be able to edit it, it should probably check the WP commenting cookie at least.

    Thanks,
    Martin

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Editable Comments] issue with timezone offset’ is closed to new replies.