Date Display incorrect

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
ppbedz
Experienced User
Posts: 147
Joined: Tue Jun 17, 2014 4:00 pm
First Name: Patti
Last Name: Bednarz
Company Name: McGard
State / Province: New York
Country: United States
Contact:

Date Display incorrect

Post by ppbedz »

I have some code on an onchange event that will populate a date widget with the current date if the status from a drop-down is changed to "accepted". I have the code working, however the date is displayed as a full date with text and time (see attachment). The date format on the date widget is defined as mm/dd/yy? How can I get my date to display properly?

Thank you,
Patti
Attachments
displaydate.docx
(98.43 KiB) Downloaded 82 times
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Date Display incorrect

Post by Scott Klement »

The formatting on the binding dialog only affects data that is loaded from the bound variable. Or, to put it another way, the binding format is only used when loading data from DDS/RPG, it is not used when loading data from JavaScript.

You'll need to format your date in the JavaScript code.
ppbedz
Experienced User
Posts: 147
Joined: Tue Jun 17, 2014 4:00 pm
First Name: Patti
Last Name: Bednarz
Company Name: McGard
State / Province: New York
Country: United States
Contact:

Re: Date Display incorrect

Post by ppbedz »

Scott, Can you help me out with that? I am still a little clumsy with these date objects. Thank you, Patti
User avatar
Glenn
Profound Logic Staff Member
Posts: 124
Joined: Mon Apr 14, 2014 4:08 pm
First Name: Glenn
Last Name: Hopwood
Company Name: Profound Logic Software
State / Province: Ohio
Country: United States
Contact:

Re: Date Display incorrect

Post by Glenn »

Patti,

The code below should get you what you need. I've added comments to the code to clarify some things.

Code: Select all

var today = new Date();

// getMonth() returns 0 - 11 (need to increment to match 'normal' dates)
//   Note that it will NOT have leading zeroes
var mm = today.getMonth()+1; 
// Add leading zeroes, if needed
if (mm < 10) {
    mm = '0' + mm;
} 

// getDate() returns the 'day' portion of the date - Note that it will NOT have leading zeroes
var dd = today.getDate();
// Add leading zeroes, if needed
if (dd < 10) {
    dd = '0' + dd;
} 

// getFullYear() returns YYYY - Use substring to get the last 2
var yy = today.getFullYear().toString().substr(2,2); 

var todayDate = mm + '/' + dd + '/' + yy;
alert(todayDate);

Glenn
ppbedz
Experienced User
Posts: 147
Joined: Tue Jun 17, 2014 4:00 pm
First Name: Patti
Last Name: Bednarz
Company Name: McGard
State / Province: New York
Country: United States
Contact:

Re: Date Display incorrect

Post by ppbedz »

Thank you, Glenn!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests