set datetime field to specific output format

Avatar

Avatar

scottb6639504

Avatar

scottb6639504

scottb6639504

03-09-2019

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!

Accepted Solutions (0)

Answers (3)

Answers (3)

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372
_Bruce_Robertson
MVP

03-09-2019

Try using

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

For you second question, what are the values of TreatTimezone

Avatar

Avatar

scottb6639504

Avatar

scottb6639504

scottb6639504

04-09-2019

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

Avatar

Avatar

scottb6639504

Avatar

scottb6639504

scottb6639504

04-09-2019

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)