• Resolved chuckcoker

    (@chuckcoker)


    The [wpdts-custom format="U"] produces the wrong value. For example, it produces 1631485440, when it should produce 1631510640. The “U” parameter is for the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). This value seems to be off by -25200 seconds (-7 hours), the local time zone offset. In other words, the 0 time would have been January 1 1970 00:00:00 PDT (Pacific Daylight Time, America/Los Angeles), which is incorrect.

    There are many ways to get the Unix Epoch so this isn’t a show stopper, but if you need accurate time, this won’t do it.

    Can anyone tell me if this is a bug or was it done on purpose for some reason I’m unaware of? Thanks.

    • This topic was modified 3 years, 2 months ago by chuckcoker.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Ivaylo Tinchev

    (@itinchev)

    Hello @chuckcoker,

    Can you please check if you have setup your timezone in WordPress General Settings correctly? The result is generated based on the timezone of your WordPress installation.

    Thread Starter chuckcoker

    (@chuckcoker)

    @itinchev Thanks for the quick reply.

    My timezone is set to America/Los Angeles in the WordPress settings. That is my local timezone.

    The problem is that the Unix Epoch is displayed adjusted for my timezone. The Unix Epoch is the same everywhere in the world at the same moment—the number of seconds that have elapsed since January 1, 1970 UTC/GMT, not counting leap seconds. The Unix Epoch is exactly the same whether I’m in Moscow or London or New York. There should not be an adjustment for timezone.

    Plugin Contributor Ivaylo Tinchev

    (@itinchev)

    Hello again,

    The idea behind the commented shortcode activity is to get the UNIX timestamp for the current timezone at the time when the original timezone is set. If you would like to get the original timezone of the UNIX Epoch time you will need to subtract or add hours e.g. [wpdts-custom format="U" hours="-7"] where -7 is the difference with your timezone.

    Thread Starter chuckcoker

    (@chuckcoker)

    After some trial and error I found that you need to add your offset hours to the returned time to get UTC/GMT. For my -0700 time zone I need to use [wpdts-custom format="U" hours="+7"] instead of -7.

    How do you deal with fractional time zones? For example, we have some Canadian customers and Newfoundland is -0230 (daylight saving time) and -330 (standard time).

    [wpdts-custom format="U" hours="+2.5"] returned a value that was 5 hours off, so I tried minutes and [wpdts-custom format="U" minutes="+150"] returned a value that was 4.5 hours off.

    Thanks.

    • This reply was modified 3 years, 2 months ago by chuckcoker.
    Plugin Author Denra.com

    (@denra)

    Hi,

    You need to add minutes=”…”. e.g.
    [wpdts-custom format="U" hours="+2" minutes="+30"]

    Please look at the description of the plugin for more information on this.

    Plugin Author Denra.com

    (@denra)

    Hello,

    This thread will be closed as resolved. Please open a new one if you need additional support.

    Thank you for using our plugin.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Seconds Since the Unix Epoch Bug?’ is closed to new replies.