x-fran / g-trends

Google Trends API for PHP
https://tarlabs.es
MIT License
112 stars 47 forks source link

Getting Data not match with Google Results #39

Closed nishanthr93 closed 3 years ago

nishanthr93 commented 3 years ago

Hi, I am trying to get interest over time data. I get successfully. when I match with google results in it not looks correct. I think the issue in the timezone. can anyone help me?

use Google\GTrends;

$options = [
        'hl'  => 'en-US',
        'tz'  => -60, # last hour
        'geo' => 'IN',
    ];

$gt = new GTrends($options);

print_r($gt->interestOverTime('Donald Trump'));

image

image

nishanthr93 commented 3 years ago

Google uses the current time zone in minutes. I getting my current time zone in minutes by Js.

 var dt = new Date();
 var tz = dt.getTimezoneOffset(); 
 document.write("getTimezoneOffset() : " + tz ); 

Now the result data is matched.