need javascript code to populate field with current date

2,911 views
Skip to first unread message

george

unread,
Jul 8, 2008, 5:40:38 PM7/8/08
to Adobe LiveCycle Developers
need javascript code to populate field with current date in Mar 13,
2008 format
thanks for your help.

sru...@gmail.com

unread,
Jul 9, 2008, 8:54:12 AM7/9/08
to Adobe LiveCycle Developers
Hi,

There is a readymade field available for this purpose. Current
Date field in the Custom palette. Just drag and drop the field. Code
is present in its layout-ready event. Change the date format to "2".
And there you are!

Alternatively, use a standard date/time field and paste this script in
the field event - layout-ready and language-formcalc

// Current Date in short-style date format.

$.rawValue = num2date(date(), DateFmt(2))

Ramya.

george

unread,
Jul 9, 2008, 9:44:56 AM7/9/08
to Adobe LiveCycle Developers
thanks for your help

george

unread,
Jul 9, 2008, 9:50:46 AM7/9/08
to Adobe LiveCycle Developers
but does anyone know the javascript way to get the current date as
well???? and alter the format?

JavaJones

unread,
Jul 10, 2008, 5:01:13 PM7/10/08
to Adobe LiveCycle Developers
try this
this.rawValue = printd("MM/DD/YYYY",new Date());

sru...@gmail.com

unread,
Jul 11, 2008, 12:25:35 PM7/11/08
to Adobe LiveCycle Developers
ya right.....

the exact syntax for your required format would be...

this.rawValue = util.printd("mmm dd,yyyy", new Date());

Ramya...
> > > > > thanks for your help.- Hide quoted text -
>
> - Show quoted text -

Duane Nickull

unread,
Jul 13, 2008, 10:30:47 PM7/13/08
to live...@googlegroups.com
Just a quick note.  This gets the date based on the users system.  If you want to make sure the user cannot spoof dates, there are more complicated workarounds but I haven't tried lately.

/dc
--
******************************
Speaking only for Duane's World
http://www.duanesworldtv.org/
http://technoracle.blogspot.com
"I don't know what I want to be when I grow up"
******************************

george

unread,
Jul 14, 2008, 9:19:21 AM7/14/08
to Adobe LiveCycle Developers
thanks for everyone's help. I think I've got enough info.
> Speaking only for Duane's Worldhttp://www.duanesworldtv.org/http://technoracle.blogspot.com

TS

unread,
May 4, 2015, 11:02:41 PM5/4/15
to live...@googlegroups.com
If you want to populate the field with the date, and lock it down so it doesn't change/update each time the PDF form is opened use this:
    if(this.rawValue == null) 
    { 
           this.rawValue = util.printd("mm/dd/yyyy   HH:MM", new Date()); 
    }else{} 
Reply all
Reply to author
Forward
0 new messages