Current local time or lolcal time zone code (example, as EST), not as Eastern Standard Time | Community
Skip to main content
MSR1306
Level 4
February 28, 2014
Solved

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

  • February 28, 2014
  • 8 replies
  • 5568 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by _Bruce_Robertson

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

8 replies

MSR1306
MSR1306Author
Level 4
February 28, 2014

Any help pls.?

Thank you

Level 4
February 28, 2014

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?

MSR1306
MSR1306Author
Level 4
February 28, 2014

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

Level 4
February 28, 2014

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?

MSR1306
MSR1306Author
Level 4
February 28, 2014

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

_Bruce_Robertson
_Bruce_RobertsonAccepted solution
Level 10
March 1, 2014

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

MSR1306
MSR1306Author
Level 4
March 2, 2014

Perfect, Thank you

MSR1306
MSR1306Author
Level 4
September 4, 2014

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