Skip to content

Instantly share code, notes, and snippets.

@TastyToast
Created May 24, 2012 17:32
Show Gist options
  • Save TastyToast/2782958 to your computer and use it in GitHub Desktop.
Save TastyToast/2782958 to your computer and use it in GitHub Desktop.
Formatting the date for page manager sweeps
<div id="start-date">
{{ my_sweeps.start_date }}
</div>
<script src="https://s3.amazonaws.com/wildfireapp/assets/momentjs/moment.min.js" type="text/javascript"></script>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
function formatDate(date) {
formattedDate = date.text();
var d = moment(formattedDate, "YYYY-MM-DDTHH:mm:ss");
$(date).html( d.format("dddd, MMMM Do YYYY, h:mm:ss a"));
};
formatDate($('#start-date'));// here we pass in our element we would like to replace only works for ID's
//if it's a class....
$('.entry-date').each(function() {
formatDate($(this));
});
});
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment