Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to add an alternative to CURRENT_DATE to your Salsa page. The date is formatted like "November 5, 2017", making it perfect for autoresponses and thank you pages.
<!-- BEGIN Add a pretty version of today's date in a field called 'alt_comment_date field. -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.13/moment-timezone-with-data.js"></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
var target = document.querySelector("#put-alt-current-date-here");
if (target == null) { return; }
var e = document.querySelector('input[name=alt_current_date]');
e.value = moment.tz('America/New_York').format('MMMM D, YYYY');
document.querySelector('.salsa form').appendChild(e);
});
</script>
<div style="display: none;">
<input type="hidden" name="alt_current_date" />
</div>
<!-- END Add a pretty version of today's date in a field called 'alt_comment_date field. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.