Current time option | Community
Skip to main content
New Participant
April 28, 2022
Solved

Current time option

  • April 28, 2022
  • 2 replies
  • 1363 views

Hello,

 

I wanted to ask if there is possibility to have a time field that has two options:

1. The time we enter manually

2. Current time

 

It would be similar to the Date field where we can choose any date or today's date.

 

Thanks for your help!

Magda

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 Mayank_Gandhi

try this on initialize

 

var event = new Date();

field.rawValue=event.toLocaleTimeString('en-US');

2 replies

Mayank_Gandhi
Employee
May 2, 2022

@magdabryla What kind of form is it? PDF or Adaptive?

New Participant
May 3, 2022

@mayank_gandhi it's pdf.

 

Mayank_Gandhi
Mayank_GandhiAccepted solution
Employee
May 4, 2022

try this on initialize

 

var event = new Date();

field.rawValue=event.toLocaleTimeString('en-US');

MHWinter
New Participant
April 29, 2022

I am not sure if you can do it as you suggest but you van have a button next to your time field that set the value of the TimeField to the current time. Like this

If the TimeField format as HH:MM, the script in the click event of the button would be something like:

var d = new Date();
var ThisHour = d.getHours();
if (ThisHour<10) {ThisHour= "0"+ThisHour}
var ThisMinute = d.getMinutes();
if (ThisMinute <10) {ThisMinute = "0"+ThisMinute }
TimeField1.rawValue = ThisHour + ":" + ThisMinute;