Skip to main content
Inspiring
September 4, 2023
Answered

util.printd Time

  • September 4, 2023
  • 1 reply
  • 1190 views

Hi
I have a field called "Start Time" where I can write the time
The format set for the field is Hour HH.MM
In the field I wrote 10:00 which becomes 10.00
I wrote this function in the console, but the result is not correct
var StartTime = this.getField("Start Time").value;
util.printd("hh.mm",new Date(StartTime));

result 12.01

Please can someone help me find my mistake?

This topic has been closed for replies.
Correct answer try67

You can't create a new Date object from just a time, it's not enough. I don't understand why you want to use printd at all, though. Just copy the value directly. If needed, change the colon to a period, like this:

 

event.value=StartTime.replace(":", ".");

1 reply

try67
Community Expert
Community Expert
September 4, 2023

The format setting only changes what the value of the field looks like, not the actual value.
If you enter "10:00" that's the value you will get when accessing the field's value (or valueAsString) property.

ENE5CD9Author
Inspiring
September 4, 2023

Okay
But what should I write to have the same result in the "Start time" field and in the "text1" field, where I insert the function
var StartTime = this.getField("Start time").value;
event.value=util.printd("hh:mm",new Date(StartTime)); ?
I ask this because, if I write 10:00 in the "Starting time" field, 10.00 appears and the "text1" field where I entered the formula shows 12.01
I would like the same value as the "Start time" field to appear in the "text1" field as well

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 4, 2023

You can't create a new Date object from just a time, it's not enough. I don't understand why you want to use printd at all, though. Just copy the value directly. If needed, change the colon to a period, like this:

 

event.value=StartTime.replace(":", ".");