Time in reports seems to be off

WPPizza – A Restaurant Plugin for WordPress Support General Support Time in reports seems to be off

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #4510
    florian
    Participant

      Hi Olly

      Something you might want to look into. In the reports page in the admin screen, the Timezone seems to be a little off. We are running your plugin and wordpress with timezone set to Seoul (UTC+9). Even though we are quite a bit ahead of most other country, some of our orders are recorded on the next day. In this screenshot you can see what I mean. In the bottom right you have the current time (that’s the same that wordpress is set to). And then some of today’s orders are shown as ordered tomorrow.

      Not really a critical bug but you might want to look into it. Tell me if you need more details.

      http://www.webtopf.ch/stuff/bug_timezone.jpg

      The total amount of the two days matches the total amount of today if I add the orders in “Order History”

      #4512
      Olly
      Admin & Mod

        i’ll see if i can replicate it and what’s going on

        thanks

        #4513
        Olly
        Admin & Mod

          can you send me a screenshot of your order history to dev[at]wp-pizza.com (or just an image here / set to private or not)?
          (just the top 20 orders would do i suppose)

          #4515
          florian
          Participant

            Sent to you in an email.

            #8622
            Shareef El-Hamawy
            Participant

              Olly,

              FYI. I have the same issue I am -5 (Eastern Standard Time) had to use -4.

              #8634
              Olly
              Admin & Mod

                a) make sure your timezones are set correctly (wp->general->settings, as well as in the php.ini)

                b)furthermore, i know of other plugins, that change/override/disregard the timezone settings and just use UTC for example. nothing i can do about other plugins messing around with or totally ignoring those settings.

                Having said that, I know that with some/many plugins it tends to be better to use actual timezones (in the wordpress setup) like “london/europe” as opposed to “UTC -3” (or whatever would appropriate). certainly worth a try …

                c) always a chance that this bit/behaviour is something my end.
                however, in all events so far i have only ever found that other plugins mess this up or the timezones (wp / php.ini) are not set correctly

                #8639
                florian
                Participant

                  Since this came up again, I noticed that it still isn’t working right for our setup. We set wordpress to the right timezone. But I think our database and webserver are both configured with different timezones.

                  Am I right to assume that the plugin saves and displays datetimes only from wordpress’ setting? Can database or webserver settings have any effect on the report screen?

                  #8652
                  Olly
                  Admin & Mod

                    >But I think our database and webserver are both configured with different timezones.

                    that’ll be why then

                    >Can database or webserver settings have any effect on the report screen?
                    absolutely

                    #8669
                    florian
                    Participant

                      I’m curious now, wouldn’t it be better to store all the dates inside the plugin as UTC and then use wordpress’ timzone setting for the presentation?
                      I’ve developed another application where we stored dates in local time. and when we tried to run it in a different environment/timezone we ran into a lot of problems because of that. Since then I always store and compare dates/times as UTC and only convert it to local times for the frontend/admin output.

                      Would that be too much of a risk for the whole plugin? Or is there a reason that makes it a bad idea?

                      Also see this interesting summary:
                      http://stackoverflow.com/questions/2532729/daylight-saving-time-and-time-zone-best-practices

                      #8678
                      Olly
                      Admin & Mod

                        first of all, the only times that actually get stored are the order and update time in the order table (as far as i remember anyway) and there is no calculation going on there as it just uses a mysql timestamp. (a bit more about this below)

                        secondly – and more importantly as far as i am concerned – consider the following:
                        store order time as UTC.
                        go to admin ->reports which – obviously – uses the times stored in the order table to figure out when was what order done.
                        if UTC, convert the timestamp to WP time with some function, multiply by 1000’s
                        if *not* UTC, do not run a function , multiply function to run by == 0
                        (same would be the case for various other places, just not that excessively)

                        furthermore. the order time SHOULD be fixed to the timezone here in my book.
                        if i make an order at 4PM at the timezone we are in it was still at 4PM 10 months later when the server moves elsewhere and their timezones are different, not suddenly at 6PM or 2PM or whatever

                        although nothing to do with reports, there seems to be a transient issue with wordpress under certain circumstances
                        https://wordpress.org/support/topic/set_transient-seem-to-use-server-time-regardless-of-timezone

                        lastly, i have also seen plugins that totally disregard other plugins and overwrite/change wp time with their own stuff screwing everybody else. So it does not make any difference what time YOUR plugin is using as someone else thinks THEIR time should be used

                        in any case, all of the above is not ever a problem if the timezones match.
                        i know of some hosting companies arguments , that the server time should be utc because visitors to the site come from all parts of the world. as far as i am concerned, this is complete rubbish as the server itself (and the shop that is running on that server) is NOT in different parts of the world but in a very distinct location

                        regarding the mysql timestamp. currently it inserts the time into the timestamp column by itself so to speak (there’s not insert time() into timestamp_column)

                        one could probably change that to do insert wp_time into timestamp_column which should at least overcome the times saved are being wp_times , regardless of php.ini settings.
                        i will mull this over for a bit

                        #8679
                        Olly
                        Admin & Mod

                          and with regards to the link you posted. the following applies here as far as i am concerned

                          Event time: eg, the time when an international sporting event happens, or a coronation/death/etc. This is dependent on the timezone of the event and not of the viewer.

                          #8681
                          Olly
                          Admin & Mod

                            lol
                            >if UTC, convert the timestamp to WP time with some function, multiply by 1000’s

                            what i said there is of course nonsense.
                            one would recalc the current time to UTC once of course and then compare the db entries as opposed to recalculating every db entry and comparing them to current time..
                            anyway though, the rest still applies

                          Viewing 12 posts - 1 through 12 (of 12 total)
                          • The topic ‘Time in reports seems to be off’ is closed to new replies.