Hi,

I am looking to add a timezone offset to start_time and end_time of the historical search API query. I am following this Timezones | Docs | Twitter Developer Platform, but it returns me an error.

Exception: (400, '{"errors":[{"parameters":{"start_time":["2023-01-13T00:00:00-0500"]},"message":"The 
`start_time` query parameter value [2023-01-13T00:00:00-0500] is not a valid RFC3339 date-time."},
{"parameters":{"end_time":["2023-01-13T05:30:00-0500"]},"message":"The `end_time` query 
parameter value [2023-01-13T05:30:00-0500] is not a valid RFC3339 date-time."}],"title":"Invalid 
Request","detail":"One or more parameters to your request was 
invalid.","type":"https://api.twitter.com/2/problems/invalid-request"}')

Basically I want to get tweets according to EST timezone.

Any help/guidane would be very appreciated.

Thanks,
Saurabh

@Saurabh_Joshi ,

I don’t know your request, but at least the Twitter API servers can only handle UTC time. So you should calculate the time in the time zone you want to use and convert that date time to UTC.

3 Likes

Okay, yeah I tried that, but the thing is I get different time when created_at is displayed and different time under the actual tweet.

To be more specific about the work:
I have made a streamlit dashboard and have connected Twitter API with it. So whenever I set the time from st.time_input, I usually get tweets according to UTC. But I want the tweets as per EST and selected time from input component.

→ select time, eg: 7:30 am EST
→ All the tweets should show up from 7:30 am EST

but here, I am getting different tweets (acc. to UTC timezone). I am not sure how can I acheive this.

any help would be appreciated.

Thanks
Saurabh

You will have to convert to EST in your UI in that case, both times, when taking user input in EST, convert to UTC for the query, and then when getting the created_at in UTC convert it to EST for display. The ads API works different to the rest of the API as far as I remember, so if it’s a call made to ads API it’s a different question.

2 Likes