2014-03-10

TweetPHP : why the time is invalid?

I found problem on the time. FYI I'm setting in twitter using my country date (+7). Then I posted in January, 1 2014 19:00.. but the date said January 2....? first I check on my code

date_default_timezone_set('..');//I place my date here
$TweetPHP = new TweetPHP();

It seem this related to
date_default_timezone_set();
then I type
date_default_timezone_set('UTC');
$TweetPHP = new TweetPHP();

and worked fine?! but before I tried this step to found out something interested

TESTING

This testing related to twitter setting and my script!

TEST 1 TEST ON DUMMY

Twitter : using +7 time
my script : not using date setting 
This test not using any date_default_timezone_set(). I testing there is no problem. The twitter show fine?

TEST 2 TEST USING DATE SETTING

Twitter : using +7 time
my script :  using date setting 
This test using any date_default_timezone_set(). I testing there is a problem! the time is forward to 7?!?

TEST 3 EDIT TWITTER TIME

Twitter : using gmt
my script :  using date setting 
This test using any date_default_timezone_set(). Don't forget I'm using GMT on twitter. Normaly I should have correct time. I testing there is a problem! the time is forward to 7?!? This is very strange actualy. Then I change back into my original time.

CONCLUSION

I think using UTC
date_default_timezone_set('UTC');
before execute $TweetPHP = new TweetPHP(); is better option. But I suggested before you run any code that called the twitter API. After done tried to return you timezone back. I like to add date_default_timezone option and put new line that related to date_default in the TweetPHP file. But I think is wise not to edit any code inside.

Tidak ada komentar: