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

Setting default time in a date/time field.

geophray
Registered: Jun 13 2008
Posts: 40
Answered

Hi,

I am trying to set the default time on a date field to be 12:00 pm (noon) for whatever date is entered.

Also, does the time need to show, or can it still record a time but only show a date in the field? I know you can format it that way but am not sure if the time is recorded if it is not formatted to display it.

If you have any questions about what I am trying to do, please let me know. I appreciate any help on this in advance...

Jeff

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You can specify the data and time format either by the picture format or by using Acrobat JavaScript in Acrobat or FormCalc or JavaScript in LiveCycle Designer.

Form really custom formats, in Acrobat you can use the "utiol.printd(sFormat, oDateTime)" in LiveCycle Designer you can use FormCalc's "Date2Num()" and 'Num2Date()" functions.

George Kaiser

geophray
Registered: Jun 13 2008
Posts: 40
Thank you for your quick response! I am still a little lost about how to do this... Let me give you some more details on what I want to do.

I have a field named "Funding Date", that I want the user to enter a date in. When they enter it, there will be a calculation that will compare it to another date that is set with a time stamp when they submit the form. I want the time in the Funding Date field to always be 12:00 noon for the purposes of the calculation, regardless of when they enter it, but I don't actually want it to show in the field. I'm not sure if what you already told me addressed this, because I am definitely not an expert... :)

Let me know if that makes sense...

Thanks!
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
For Acrobat JavaScirpt:

// get the current date timevar sNow = new Date(); // get current dateconsole.show();console.clear();// display the current date timeconsole.println("It is : " + sNow);// display formatted date onlyvar sNowDate = util.printd("mmm dd, yyyy", sNow);console.println("Today's date is: " + sNowDate);// set date time object to today at 12:00 pmoNowNoon = util.scand("mmm dd, yyyy hh:mm tt", sNowDate + " 12:00 pm");console.println("Noon today is: " + oNowNoon);// add 1 hour 30 minutes to today at noon// one second is 1,000 millisecondsvar fSec = 1000;// one minute is 60 secondsvar fMin = 60 * fSec;// one hour is 60 minutesvar fHr = 60 * fMin;// add 1 hour 30 minutes 15 seconds to today at noon. var fNowNoonAdvance = oNowNoon.valueOf() + (1 * fHr) + (30 * fMin) + (15 * fSec);// convert to date time objectvar oNowNoonAdvance = new Date(fNowNoonAdvance);// display resultconsole.println("Today noon plus 1:30:15 = " + oNowNoonAdvance);event.value = sNowDate;

Will produce on the JavaScript console:
Quote:
It is : Wed Mar 04 2009 12:30:44 GMT-0600 (Central Standard Time)
Today's date is: Mar 04, 2009
Noon today is: Wed Mar 04 2009 12:00:00 GMT-0600 (Central Standard Time)
Today noon plus 1:30:15 = Wed Mar 04 2009 13:30:15 GMT-0600 (Central Standard Time)
You also might want to read Thom Parker's tutorials about date and time calculations [url=http://www.acrobatusers.com/tutorials/2006/date_time_part1]Working with date and time in Acrobat JavaScript (Part 1 of 3)[/url].

George Kaiser

geophray
Registered: Jun 13 2008
Posts: 40
Thank you. That was just what I needed. :)