0

I live in Brazil. Here we have 4 different timezones.

The company I work already have a windows software that doesn't care about the timezone, so it always gets the time of the system, but now I'm implementing a web app that synchronize everything.

Now I'm only working with America\Sao_Paulo and obviously got some problems in a country that have 4 timezones

I have multiples questions about who is responsible for caring about the timezone:

  1. When storing some time, should the front, send the local time to the server and the server store in this case America\Sao_Paulo or the front should send always America\Sao_Paulo?
  2. When getting the date form the server, should it return in America\Sao_Paulo or the time that the system wants?
Mohsen Alyafei
  • 4,765
  • 3
  • 30
  • 42
SpaceDogCS
  • 2,808
  • 3
  • 20
  • 49
  • 1
    These things vary considerably depending on exactly what the specific function you're working on needs to do. If you're looking for a one-size-fits-all answer, you may very possibly the wrong logic. Think through what you're trying to do and what behavior you need. Also, there's a ton of information about time zones already on Stack Overflow, under the [tag:timezone] tag. You might want to start with [Daylight saving time and time zone best practices](https://stackoverflow.com/a/2532962/634824). – Matt Johnson-Pint May 26 '20 at 03:09

1 Answers1

1

What if you work with GMT and apply timezone only if you need to print the data in the UI.

  • That's what I was thinking about, instead of GTM I would use America/Sao_Paulo by default because it already has an entire software using it, my doubt is if the front should send ton the API its local time or the `America/Sao_Paulo` (or GMT, doesn't matter in this case) – SpaceDogCS May 26 '20 at 00:34
  • 1
    got it. I`d send it in America/Sao_Paulo to keep data in the backend consistent. – Wellington Costa May 26 '20 at 02:14
  • 3
    1) It's "GMT", not "GTM" - and preferably you should use the term "UTC" for this concept. 2) The advice you gave applies to *some* scenarios, but not all of them. There is not a one-size-fits-all answer for this question. – Matt Johnson-Pint May 26 '20 at 03:12