Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Return system date

Avatar

Level 4
Apologies if this has been answered before... but I really did search the forum and couldn't find specifically what I was looking for.



I'm trying to automatically get the current date which I found -- ($.rawValue = num2date(date(), DateFmt(4)). However the 4 date formats available do not meet our standard format of YYYY-MM-DD. Is there a way to get the current date to automatically display in this format, including the padded two-digit month and day fields?



AND once the date field is filled in... it is "locked" into place so when the document is opened again, the original date is not replaced by the new "current date".
6 Replies

Avatar

Level 4
HELP PLEASE!!!!



Even if the answer is "No, it can't be done" will suffice.

Or a redirect to where I can get the info.



Thanks.

Avatar

Former Community Member
In Javascript, maybe something like this..



if (this.rawValue == "null")

{



this.rawValue = util.printd("YYYY-MM-DD", new Date());



}



Maybe you have to change the Display pattern (OBJECT TAB --> FIELD TAB) to YYYY-MM-DD (?)



check & let me know! also check whether it submits in that format.. Rarely can I get something to work the way i want it to in Designer :|

Avatar

Level 4
THANKS so much for the effort Chris... it was appreciated. Unfortunately the script didn't work. I didn't get any error messages but the date didn't display either.



Oh well, I'll advise my users auto dates are not available (since I cannot break our corporate data standard format).



I'll certainly be adding this to the wish list for the next version (hopeful I know)!

Avatar

Former Community Member
Hi,



Try this:



if (this.rawValue == null){ //without "null"

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

}



Hope be usefull!,

Avatar

Former Community Member
Hi again,



In date format don´t put YYYY/DD/MM in caps, put just yyyy/mm/dd.



I try this in my forms, and it work fine.

Avatar

Level 4
Marta -- THANK YOU, THANK YOU, THANK YOU. This worked perfectly!



I've added it to my Custom Library!!