Expected start_time to be precisely aligned at midnight in timezone America\/Santiago for granularity Some(DAY), got \"2016-05-15T03:00:00Z\" for


Ok I realize this is a confusing one, but the way you have to call is like this:
twurl -t -H ads-api.twitter.com '/1/stats/accounts/18ce53x6d8b?entity=ACCOUNT&start_time=2016-05-13T00:00:00-03:00Z&end_time=2016-05-15T00:00:00-04:00Z&granularity=DAY&metric_groups=BILLING&placement=ALL_ON_TWITTER'

The end time in v1 is exclusive, meaning it will include up until that minute but not including it. Because the time zone of that minute is already a different time zone definition, you have to pass it the new time zone offset (I’m not sure if this makes sense or not, will try to discuss it internally and compare vs old behavior).

Then after that 15th, you can call with the correct UTC-4 on both start and end:
twurl -t -H ads-api.twitter.com '/1/stats/accounts/18ce53x6d8b?entity=ACCOUNT&start_time=2016-05-20T00:00:00-04:00Z&end_time=2016-05-26T00:00:00-04:00Z&granularity=DAY&metric_groups=BILLING&placement=ALL_ON_TWITTER'




Also, this appears to work as well: twurl -t -H ads-api.twitter.com ‘/1/stats/accounts/18ce53x6d8b?entity=ACCOUNT&start_time=2016-05-13T00:00:00-03:00Z&end_time=2016-05-17T00:00:00-04:00Z&granularity=DAY&metric_groups=BILLING&placement=ALL_ON_TWITTER’

So, I would just do a lookup of something like “if calendar_date > DST, -4, else, -3” for both start and end date.


Thank you, @JBabichJapan, for helping with this.

@Asad: in PHP, you can get the timezone offset with this: http://php.net/manual/en/datetime.getoffset.php


Thanks @JBabichJapan ,@majoritasdev
thats right if send in both the hours 4 after 15 it sucess but, for this timezone i got the midnight hour is 3 ,
even if i try with the postman that there is no enetred hour it will failed after 15 ,
pictures attached ,

timezone before 15

timezone after 15


I’m not sure what’s going on when you leave the hours off but you should be able to send it in a combination of UTC-3 and UTC-4 for the case where the start time and end time ‘straddles’ the DST cut over (without error).


@JBabichJapan: the Z in 2016-05-13T00:00:00-03:00Z is redundant - the timezone is already specified by -03:00, and Z is (fortunately) ignored (in PHP anyway). (fyi, @juanshishido)

@Asad: did it work for you like @JBabichJapan said? Because I had the impression that you already tried this variant and didn’t work.

Stats endpoint start_time and end_time formats

Hi @majoritasdev,
yes it was long time ago and yes i tried like @JBabichJapan and it succesed , there another issue opended for chile when they changed again they timezone on 14/8 on chile 14/8

and also got workaround (i hope fix will be soon, i will not change the code spically for chile)
anyway that alot @majoritasdev for your answer.



You’re welcome. Glad to hear it succeeded! :slight_smile:


Hello @JBabichJapan,
I am facing the exact same problem here and I am trying all the possible combinations of hours without hope.
My twurl giving me the “Expect time to be midnight in the account’s local timezone for day granularity” error:

twurl -H ads-api.twitter.com "/2/stats/accounts/18ce548xann?start_time=2017-10-08T00:00:00-03:00Z&end_time=2017-10-15T00:00:00-03:00Z&entity=CAMPAIGN&entity_ids=8t4m1&granularity=DAY&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER" -X GET | python -m json.tool

Daylight saving in Brazil starts at the 15th, so calling

twurl -H ads-api.twitter.com "/2/stats/accounts/18ce548xann?start_time=2017-10-08T00:00:00-03:00Z&end_time=2017-10-14T00:00:00-03:00Z&entity=CAMPAIGN&entity_ids=8t4m1&granularity=DAY&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER" -X GET | python -m json.tool

works fine.

I can handle this with code, but I need to some logics to follow. None of my trials are working to call reports ending on the 15th.

And there is one more WTF moment, if I call this report as an async one, it works.

twurl -H ads-api.twitter.com "/2/stats/jobs/accounts/18ce548xann?start_time=2017-10-08T00:00:00-03:00Z&end_time=2017-10-15T00:00:00-03:00Z&entity=CAMPAIGN&entity_ids=8t4m1&granularity=DAY&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER" -X GET | python -m json.tool

And a big question, after all: why do we need to send timezone since it is forbidden to use a different timezone and twitter knows on its side the timezone of the account. I sincerely hope it gets fixed on next versions. (this is a more abroad question that maybe is out of the scope of this thread)

Critical bug on Twitter´s Report Panel?
Critical bug on Twitter´s Report Panel?

Well, it appears like there is a bug on Twitter side that it can´t handle the fact that THERE IS NO midnight when Daylight saving time (DST) starts.
This is how the clock goes:

2017-10-14 23:59:59.999998 UTC-03:00 (BRT)
2017-10-14 23:59:59.999999 UTC-03:00 (BRT)
2017-10-15 01:00:00.000000 UTC-02:00 (BRST)
2017-10-15 01:00:00.000001 UTC-02:00 (BRST)

So if I call with start date out of DST and end date after the beginning of DST with the proper clock changes it works fine:

twurl -H ads-api.twitter.com "/1/stats/accounts/18ce548xann?start_time=2017-10-14T00:00:00-03:00Z&end_time=2017-10-16T00:00:00-02:00Z&entity=CAMPAIGN&entity_ids=8t4m1&granularity=DAY&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER" -X GET | python -m json.tool

But if I try to call end date or start date being the begging of DST (15 october in Brazil) it does not work at all and it seems impossible to call reports starting or ending at this day.

This should the correct call and the API should accept it:

twurl -H ads-api.twitter.com "/1/stats/accounts/18ce548xann?start_time=2017-10-15T01:00:00-02:00Z&end_time=2017-10-18T00:00:00-02:00Z&entity=CAMPAIGN&entity_ids=8t4m1&granularity=DAY&metric_groups=ENGAGEMENT&placement=ALL_ON_TWITTER" -X GET | python -m json.tool

Please let me know if this is an actual bug or if there is a proper way to handle this.


Also, this part of the documentation seems wrong:

"When dealing with granularity DAY, any end_time that is between start_time+00:00:01 to start_time+24:00:00 will return one day of stats. Any end_time that is between start_time+24:00:01 to start_time+48:00:00 will return two days of stats. And so on. Likewise for granularity HOUR, on a per-hour basis."

The api does not accept any hour different from midnight for end_time parameter.
Always returning:
"Expect time to be midnight in the account's local timezone for day granularity"


@controledash: This seems to be related to the way we check for midnight in the account’s local timezone. Please see this post for more information, which includes a possible workaround. Thanks!


Thanks @juanshishido
I believe you guys know that this is not a “solution” to the problem. This is a hack with some serious flaws.
Take a look on this:
First report giving the results from October 14, 2017 to October 16, 2017

twurl -H ads-api.twitter.com "/2/stats/accounts/18ce548xann?start_time=2017-10-14T00:00:00-03:00Z&end_time=2017-10-17T00:00:00-02:00Z&entity=CAMPAIGN&entity_ids=8t4n8&granularity=DAY&metric_groups=ENGAGEMENT,BILLING&placement=ALL_ON_TWITTER" -X GET | python -m json.tool


"billed_charge_local_micro": [

Second report, getting only the day of October 16, 2017

twurl -H ads-api.twitter.com "/2/stats/accounts/18ce548xann?start_time=2017-10-16T00:00:00-02:00Z&end_time=2017-10-17T00:00:00-02:00Z&entity=CAMPAIGN&entity_ids=8t4n8&granularity=DAY&metric_groups=ENGAGEMENT,BILLING&placement=ALL_ON_TWITTER" -X GET | python -m json.tool


"billed_charge_local_micro": [

So for the very same day, October 16, 2017, the api is giving different cost results:
R$1,869.64 on the first report
R$1,941.00 on the second.
A difference of 4%

Since we cannot control the data ranges our users will choose and we persist data, how can we be reliable?
And at end of the day, how much our client is actually paying?

Thanks a lot for the support!


@controledash: The workaround suggested in this post was not meant to be conveyed as a solution. It’s not. There seems to be an error when we check for midnight in the account’s local timezone when there is a time change.

In addition, as you’ve demonstrated, the billed_charge_local_micro values in the response to your first request—[1947000000, 2036406914, 1869644744]—do not align with what you see in your second request.

I’ve made the stats requests for campaign 8t4n8 with hourly-granularity and see the following spend numbers:

start time end time sum of billed_charge_local_micro
"2017-10-14T03:00:00Z" "2017-10-15T03:00:00Z" 1947000000
"2017-10-15T03:00:00Z" "2017-10-16T02:00:00Z" 1947000000*
"2017-10-16T02:00:00Z" "2017-10-17T02:00:00Z" 1941000000

This matches the spend values on ads.twitter.com when I look at individual the dates.

However, when the date range is expanded to cover all three days, the numbers change.

We will take a closer look into what could be happening, but don’t have a time estimate.


* The array for this included only 23 values to account for the daylight savings time change.


Thank you so much @juanshishido!


Hey guys. Any news on that?
The problem is still there.


Thanks for the follow up, @controledash. We’re currently working to resolve other issues. This is currently in our backlog. Expect a few months before any additional news on this.


Thank you very much, @juanshishido.
It would be very helpful if you can ping this thread when you guys have a due date or the problem solved so I can update my clients.

Cheers from Brazil and keep the amazing work! :slight_smile:


Hello @juanshishido,

We are approaching SummerTime here in Brazil again.
Can we trust that there will be a solution till there?



Thanks for the follow up, @controledash. No updates to report on this; it’s still in the backlog.