Start a new topic
Answered

Timezone difference

Hello, I'm having a problem when I parse dates on the cloud.

I use 'America/Montevideo' tz, and dates have 3 hour differences on the cloud. When I run locally I get correct dates.




Best Answer

Please have a look at https://dateparser.readthedocs.io/en/latest/#timezone-and-utc-offset, there's a setting TO_TIMEZONE and other methods of converting timezone.


Scrapy Cloud is in UTC/GMT.

It happens the same if I use GMT-3

Could you explain the problem?

I parse several dates from different sources, I need these dates to be exact (time and hours). The problem is that when I transform this string to a datetime object, it's behind 3 hours. 

I tried using timezone GMT-3, UYT, America/Montevideo and still get the same 3 hour-behind dates.



Seems like you're subtracting 3:00 from the date. You should probably use a library like dateparser (https://dateparser.readthedocs.io/en/latest/) to convert the dates.

Thanks for the help nestor.


I am already using that library, in my code I have something like this: 

dateparser.parse(date_formats=["%Y%m%d%H%M"], date_string=value,
                                          settings={'TIMEZONE': 'UYT'})

I use it in a serializer method (I also declared the serializer in the Item field) 

Answer

Please have a look at https://dateparser.readthedocs.io/en/latest/#timezone-and-utc-offset, there's a setting TO_TIMEZONE and other methods of converting timezone.

Yes, it worked using TO_TIMEZONE property.
Thanks nestor.

You're welcome

Login to post a comment