Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Current local time or lolcal time zone code (example, as EST), not as Eastern Standard Time

Avatar

Level 4

Hello,

Pls. let me know the JS or FormCalc script code snippet for getting the current local time in HH:MM:SS format, or if not possible, then the current local time zone as codes, example, EST

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Try using;

util.printd("HH:MM:SS Z", new Date(), true)

Or to just get the time zone code;

util.printd("HH:MM:SS Z", new Date(), true).substring(9)

If you want a more verbose version you can use;

new Date().toLocaleFormat("%Z")

Regards

View solution in original post

8 Replies

Avatar

Level 4

In the custom Object library there is a field called "Current Date". In the Object tab of that field you can set the runtime property to be the current time and it should display the current time and time zone. For example I created a new form, selected that field, changed it to a runtime property and when I open the PDF it says "1:38:10 PM CST". Is that what you are wanting?

Avatar

Level 4

Thank you.

Actually, for some other reason I need to get local time zone, pls. let me know the JS code for to get local time zone

Regards

Avatar

Level 4

Are you saying that you want the time displayed as your local time or as the user that is completing it? The example I gave has my time zone which is Central Standard Time or CST. Did you want to convert the time to Eastern time or leave it as the time zone the user is in?

Avatar

Level 4

Sorry for confusion, let me make it simple.

1) I placed a free text feld, say its name is my_text_zone on my_form

2) Then I gonna put JS in INITIALIZATION event of my_text_zone, which determined the local time zone,as below

Example, now I'm in EST, hence I will see EST when i open the form, same for you but it's as CST

In short, I want to populate/display the user local time zone on the field / form

Thank you

Avatar

Correct answer by
Level 10

Hi,

Try using;

util.printd("HH:MM:SS Z", new Date(), true)

Or to just get the time zone code;

util.printd("HH:MM:SS Z", new Date(), true).substring(9)

If you want a more verbose version you can use;

new Date().toLocaleFormat("%Z")

Regards

Avatar

Level 4

Hello,

We are a multi national private company, located in Washington DC, we are looking for a expert LC developer with excellent JS expertise, its 3 months project, pls. reply ASAP if you are available, interviews will be immediate (no remote work pls.)

Thank you