I have a server-side code which creates html markup and sends it as an email. In the content of this email, I have added some date times. Something similar to:
Thu, 30 May 2019 08:13:24 GMT
What I want to do is to convert this date time to a local one once it was opened. I have tried the following approach:
<html>
<body>
<h1 style="color: #5e9ca0;">Hello, John Doe!</h1>
<p style="color: #2e6c80;">We kindly ask you to return it no later than: <u><span id="returnDeadline">Fri, 21 Jun 2019 09:27:37 GMT</span></u></p>
</body>
</html>
<script>
(function() {
let returnDeadlineContainer = document.getElementById('returnDeadline');
returnDeadlineContainer.innerText = (new Date(returnDeadlineContainer.innerText)).toLocaleString();
})();
</script>
If I save this and run it on my local machine it works as expected in the browser, but once I send it to the email it fails and the JS doesn't get invoked. I think there's a lot explained about this issue here: HTML email with Javascript
So, I was wondering how could I achieve this in the simplest possible way. I was looking for HTML tags (like <time>
) but they don't seem to do the trick.