Forum Discussion
convert Date from YYYY-MM-DD to MM/DD/YYYY in jQuery/JavaScript
mwilliams71 Try using:
var formattedDate = new Date("2021-09-21").toJSON();
OR
var tempDate = new Date("2021-09-21");
var formattedDate = [tempDate.getMonth() + 1, tempDate.getDate(), tempDate.getFullYear()].join('/');
Use formattedDate variable to set the date column using oListItem.set_item().
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- ganeshsanapNov 22, 2021MVP
mwilliams71 Are those two date fields "Required" in column settings/list settings? If yes, you have to make them optional from list settings.
For empty date fields, you don't have to write ".set_item()" in your code.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- mwilliams71Nov 22, 2021Brass ContributorThanks for the reply ganesshsanap. No. they are not required. However, a month later when the Status of the form change to approved, I will need to allow the user to go to the form and submit those dates.
-Mike- mwilliams71Nov 22, 2021Brass ContributorI got it to work, now it always gives me a day behind.