Difference in Script result

I’m using simple code as given below to update datetime into a tag from another tag.

import datetime

#print datetime.datetime.now()
system.tag.writeAll(["[default]BMP/Test/writeTimerLast"], [datetime.datetime.now()])

But getting time difference of 6 hours when I’m executing this code from script console (I’m using print function for testing in script console).
Result from script on the tags : 2022-09-23 01:21:07.474
Result from script in Script Console : 2022-09-23 07:21:07.472000

What may be the reason behind this time difference?

  1. Don’t use datetime.datetime.now() using system.date.now()

  2. I would guess your gateway is set to a different timezone than the computer that your running designer on

I’m using development server and this script was working in correct way before.
The Gateway timestamp is matching with the result of script console.

Just to rule it out what do you see for this tag -

and for this tag

Do they match or are they different?

Use the </> code formatting button when posting code. It will indent properly (important for Python) and give syntax highlighting. You can use the 🖉 edit link to fix your post.

1 Like

They are different, how to change [System]Client/User/Timezone?

@PGriffith please correct me if I am wrong but I believe this tag is just grabbed from the host operating system.

I don’t think you want to do this or to have this as your solution.

What exactly is the end goal you are working towards here?

Both production and development servers are in USA and I’m operating remotely from India. I want to test code on the development server which is in trial mode. Last time when I’ve tested this code (2 weeks before) it was working correctly without time difference. Since yesterday I’m facing this issue.

Note: The same code is working properly on the production servers.

You can choose a specific timezone in your project properties:

Or, if you want to force just your local client/designer to be in a specific timezone, you could add a JVM prop to the client/designer launcher - add -Duser.timezone=America/New_York or America/Los_Angeles or whatever other ID is appropriate.

I’ve resolved it by using system.date.now()
But I don’t know how it was working correctly two weeks before?
Anyways thank you all for your help :pray:

Only explanation I can think of is 2 weeks ago you remoted into the server and used Designer on that server, and today you opened up Designer on your local computer.