Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

set datetime field to specific output format

Avatar

Level 2

Hi Everyone,

I currently have a date and time field in an Adobe Dynamic XML Form, where I need the user to enter a date, time and the GMT timezone they are in.

Initially i broke this down into several fields: A date field,. and hour, minute, seconds and Timezone field which i concatonated through the following onExit Script:

var TreatDate = form1.treatvendate.rawValue;

var TreatHour =form1.treattimeH.rawValue;

var TreatMinute = form1.treattimeM.rawValue;

var TreatAMPM = form1.treattimeAMPM.rawValue;

var TreatTimezone = form1.treattimeTimezone.rawValue;

form1.DateTimeField2.rawValue = TreatDate + "T" + TreatHour + ":" + TreatMinute + TreatAMPM + TreatTimezone;

the problem I am running into into is when this concationated string is passed into the XML file when a submit button is pressed, the XML is invalid as the tag in the XML schema is expecting the following format:

<DateTime>2019-09-01T04:20:00+10:00</DateTime>

Now i get very close for an automatic date (ie getting the date the submit button was clicked) using the following Javascript:

var formattedDate = this.rawValue;

form1.subform1.DateTimeField2.rawValue = util.printd("date{YYYY-MM-DD}Ttime{HH:MM:SS}", formattedDate);

but it does not transfer across the timezone.

So my Question is two-fold:

1) how do I add the timezone requirement to

form1.subform1.DateTimeField2.rawValue = util.printd("date{YYYY-MM-DD}Ttime{HH:MM:SS}", formattedDate);

2) how do i Convert the below result into a valid datetime datatype?

form1.DateTimeField2.rawValue = TreatDate + "T" + TreatHour + ":" + TreatMinute + TreatAMPM + TreatTimezone;

Please let me know if you need additional information!

Thanks!

3 Replies

Avatar

Level 10

Try using

util.printd("date{YYYY-MM-DD}Ttime{HH:MM:SSzz}", formattedDate)

For you second question, what are the values of TreatTimezone

Avatar

Level 2

Hi there!!

thanks for the answer to the first part!!!

in relation to The 2nd part, the treatTimeZone is currently a free text field (defaulted to +10:00)

Avatar

Level 2

Alternatively, how can I concatenate two Date/Time fields, one with the date in YYYY-MM-DD format, and one with a time format of HH:MM:SSzz