• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need help formatting time only from date.

New Here ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

I've successfully created a static timestamp using the code below, but I've been struggling to get this to only display the current time calculated into HH:MM:ss only. I would greatly appreciate any help or advice this community is able to offer.

 

Custom Calculation Script:

var Text1 = this.getField("Text1").value
var Text2 = this.getField("Text2").value

if((Text1!="")&&(Text2=="")) event.value = Date(Date.now());
else if((Text1!="")&&(Text2!="")) event.value = Text2;
else event.value = "";

 

Current Output:

Sun Apr 24 2022 12:36:13 GMT-0500 (Central Standard Time)

 

Desired Output:

12:36:13

TOPICS
General troubleshooting , JavaScript , PDF forms

Views

310

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 24, 2022 Apr 24, 2022

Use this:

 

event.value = util.printd("HH:MM:ss", new Date());

Votes

Translate

Translate
Community Expert ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

Use this:

 

event.value = util.printd("HH:MM:ss", new Date());

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

Oh my God, thank you! I thought the util.printd code was only for printing, but that worked perfectly for was I need!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

LATEST

In the olden days of computer programming "printing" was used to mean displaying text, mostly on the screen, and that carried through to now, even though most people would understand it to mean printing to actual paper. I can see how that can be confusing...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines