Master Posted March 1, 2018 Report Share Posted March 1, 2018 How can I get yesterday's date and show it on a field called StartDate on a submission page in this format: mm/dd/yyyy Quote Link to comment Share on other sites More sharing options...
MayMusic Posted March 1, 2018 Report Share Posted March 1, 2018 Use this code in the footer of the submission page: <script> today = new Date(); yesterday = new Date(today); yesterday.setDate(today.getDate() - 1); var dd = yesterday.getDate(); var mm = yesterday.getMonth()+1; //January is 0! var yyyy = yesterday.getFullYear(); if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} yesterday = mm+'/'+dd+'/'+yyyy; document.getElementById("InsertRecordStartDate").value = yesterday; </script> I got this code from https://stackoverflow.com/questions/16686640/function-to-get-yesterdays-date-in-javascript-in-format-dd-mm-yyyy molly1990 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.