I currently have an HTML form that I have put together that takes the input from the user and creates an Email to be sent off to a distro list. I am having an issue with getting the date from the form to convert nicely to a different format. The current output shows and "YYYY-MM-DDTHH:MM" and I am looking to have it show "MM/DD/YYYY H:MM AM/PM"
Here is the line of Codes in HTML
<body>
<div class="row">
<div class="cell">Event Start:</div>
<div class="cell">
<div class="cell"><input type="datetime-local" id="start_dt" /></div>
</div>
</div>
<div class="row">
<div class="cell"> </div>
<div class="cell" style="text-align: center;"><button type="submit" style="width: 90%;" class="SubmitButton" onClick="createEmail();">Generate Email</button></div>
</div>
<script src="JS\testemail.js"></script>
</body>
And hers is my JavaScript
function createEmail() {
let f = document.getElementById("start_dt").value.replace("T", " ");
let m_to = "Distro_List"
let m_cc = "CC_List"
document.location.href = "mailto:" + encodeURIComponent(m_to) + "?cc=" + encodeURIComponent(m_cc)
+ " &subject=Storm Mode"
+ " "
+ "&body="
+ "%0D%0A%0D%0A"
+ "Event Start: " + encodeURIComponent(f) + "%0D%0A"
}
I have tried a few of the solutions found on SO using Librarys with momement.js
, but I can not download this onto my work machine. Here is the solution from SO that I tried to implement How to format a JavaScript date
and I tried using this site https://www.valentinog.com/blog/datetime/
I know my lack of knowledge on HTML and JS has me stumped on what I should do next. Any direction or pointers to help me on my way will be greatly appreciated.
Sorry for the messy code, I am still learning