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

70

Likes

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

Adobe Community Professional , Apr 24, 2022 Apr 24, 2022

Use this:

 

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

Likes

Translate

Translate
Adobe Community Professional ,
Apr 24, 2022 Apr 24, 2022

Copy link to clipboard

Copied

Use this:

 

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

Likes

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!

Likes

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
Adobe Community Professional ,
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...

Likes

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