This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

os.date with timezone offset
#1
Is there a smart way to get the local time using os.date(), including the DST (Daylight Saving Time)? I would not like to add a hard-coded integer to the timestamp, but instead use something that calculates it for me, based on the timezone and taking account the DST.

Actually, is there a way to set the timezone in LogicMachine, so the local time of os.date() is correct?
Reply
#2
You can set the timezone in Utilities > Date and time.
Reply
#3
(24.04.2021, 18:53)mishoboss Wrote: Is there a smart way to get the local time using os.date(), including the DST (Daylight Saving Time)? I would not like to add a hard-coded integer to the timestamp, but instead use something that calculates it for me, based on the timezone and taking account the DST.

Actually, is there a way to set the timezone in LogicMachine, so the local time of os.date() is correct?

Only os.date() reports the right time back for timezone. None of the %r or %X or %z or %Z works as they should according to strftime - no matter what is set in timezone in Utilities > Date and time.

You can get the right time for timezone by extracting the time from os.date()
ef:
TimeOfDayStr = string.match(os.date(), "%d%d:%d%d:%d%d")
Reply
#4
os.date('%z') correctly reports the timezone offset accounting the DST.
Reply


Forum Jump: