Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • c(current_time) returns UTC instead of my time zone

    Hi folks -
    See screenshot below. I'm in EDT but c(current_time) and $S_TIME display UTC. Is this behavior expected? Is there a way to see local time? I'm running Stata/SE 16.1 on Windows 10.

    Thanks!


    Click image for larger version

Name:	stata_utc.png
Views:	1
Size:	90.6 KB
ID:	1556255


  • #2
    I have edited my original post after re-reading your post.

    c(current_time), as described in the output of -help creturn- (albeit, hard to find for a new Stata user)., says

    c(current_time) returns the current time as a string in the format "hh:mm:ss", where hh is the hour 00 through 23, mm is the minute 00 through 59, and ss is the second 00 through 59.
    However, your system time and your Stata time show a discrepancy after accounting for the 12-hour and 24-hour formatting. I cannot reproduce this behaviour on my system, as the system time matches exactly. You don't appear to be using a networked license, so is it possible you could have multiple time zones on your system?
    Last edited by Leonardo Guizzetti; 31 May 2020, 18:36.

    Comment


    • #3
      SMH

      To be clear, my question was not related to the display format of c(current_time), and I did consult the helpfile for creturn list and saw no mention of time zone.

      Comment


      • #4
        Allan Massie
        Are you starting Stata from a Cygwin shell?

        Comment


        • #5
          James Hassell (StataCorp) yes, and thank you. Your question led me to https://stackoverflow.com/questions/...-cygwin-shells . I added

          unset tz

          to my .bash_profile, and it's fixed.

          Comment


          • #6
            Allan Massie you're welcome. I had a suspicion that might be the case. Thanks for the confirmation. We will add logic to Stata 16 for Windows to clear the "TZ" environment variable automatically. That way, only Stata will be impacted, and not other things that you may start from your shell. The change will be in the next update that includes the executable.

            Comment


            • #7
              Originally posted by James Hassell (StataCorp) View Post
              We will add logic to Stata 16 for Windows to clear the "TZ" environment variable automatically.
              Is it possible to make that optional for the user? Maybe show its toggle state via a c-return and make settable via set?

              I can envision users who actually want UTC in the log file and saved dataset meta-data, regardless of the local operating environment's time.

              Comment


              • #8
                Joseph Coveney I don't think the functionality you are asking for is unreasonable. However, rather than adding a new setting, that will be tricky at best to understand, we have decided to leave the behavior as it currently is, and not make the change I proposed in #6.

                Since "TZ" is only set in shell environments, a wrapper script can be written to unset or set "TZ" as desired.

                Comment

                Working...
                X