These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

date/time format

The X
Registered: Mar 27 2011
Posts: 24
Answered

I some date and time text fields. When setting the format, I have no problem using yyyymmdd for date but time has strange behavior. HHMM and hhmm pops errors when entering data in the field while yyyymmddHHMM and yyyymmddhhmm either display 0000 as the time or completely hides the content of the field when losing focus while remaining editable.
 
What is the problem?
 
Is there a difference between HHMM and hhmm and how do I use a 24-h based time format?

My Product Information:
Acrobat Pro 10.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Accepted Answer
"mm" is for months (with leading zero) and "MM" is for minutes (with leading zero). "HH" is for 24 hour time (with leading zero) and "hh" is for 12 hour time without leading zero. But the built-in format script doesn't works as you want it to when you don't include separators (which makes sense), so you'll have to create your own format script to validate the entry.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Acrobat JS has a special way to handle 12:00 am (start of the day), 12:00 pm (noon), and 12:00 midnight (actually 12:00 am the next day).

12:00 am can be entered and is the value of the field, but the util.scand method treats it like noon.
12:00 pm is treated as noon.
There is no midnight end of day for the current day.

Try the following lines of code one at a time in JS debugging console and carefully observe the results:

console.println(util.scand("m/d/yyyy hh:MM tt", "3/31/2010 12:00 am"));

console.println(util.scand("m/d/yyyy hh:MM tt", "3/31/2010 12:00 pm"));

console.println(util.scand("m/d/yyyy h:MM tt", "3/31/2010 00:00 am"));

(util.scand("m/d/yyyy h:MM tt", "3/31/2010 12:00 pm") - util.scand("m/d/yyyy hh:MM tt", "3/31/2010 12:00 am")) / (1000 * 60 * 60)

(util.scand("m/d/yyyy h:MM tt", "3/31/2010 12:00 pm") - util.scand("m/d/yyyy hh:MM tt", "3/31/2010 00:00 am")) / (1000 * 60 * 60)

The start of the day is 00:00 am.

Quote:
Is there a difference between HHMM and hhmm and how do I use a 24-h based time format?
According the the Acrobat JS API Reference for the cFormat strings for the printd and scand methods:

String - Effect - Example
mm - Numeric month with leading zero - 09
MM - minutes with leading zero - 08
HH - 24 hour time with leading zero - 09
hh - 12 hour time with leading zero - 09

I have found it is easier to enter the date and the time as separate fields.

As noted in a previous post, if you want to work with date or times as strings of numbers, JavaScript will convert you number string to a fioating point number, IEEE 754 binary format. That variable value will not have a string length nor will it always be treated as a string, since it is not considered a string within JavaScript. If you want that number value to be treated like a string, then you need to force the value to a string with the String constrictor, use the 'toString()' method, or access the field's value using the 'valueAsStrting' property.

George Kaiser

alanstein
Registered: Jun 19 2011
Posts: 1
when creating a form in LC, I place a date/time, but the form field will only accept a date. How can I set it to allow entry of time?