Skip to content

Instantly share code, notes, and snippets.

@TechFounder
Last active May 11, 2016 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TechFounder/0e1e7c03635ee9d53a794c4e42666f62 to your computer and use it in GitHub Desktop.
Save TechFounder/0e1e7c03635ee9d53a794c4e42666f62 to your computer and use it in GitHub Desktop.
SquareSpace javascript to remove day from date format
// you may need to first load jquery
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.js'></script>
$(document).ready(function () {
$('time span').remove();
});
// or if that doesn't work try this....
var monthNames = [ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" ];
$(document).ready(function () {
$("time").each( function () {
var fullDate = new Date($( this ).text());
$( this ).text(monthNames[fullDate.getMonth()] + " " + fullDate.getFullYear());
});
});
// this doesn't really work
$(document).ready(function () {
$("time").each( function () {
var parts = $( this ).text().split(" ");
parts.splice(1, 1);
$( this ).text(parts.join(" "));
});
});
// nor this
$(document).ready(function () {
setTimeout(function(){
$("time").each( function (index) {
var parts = $( this ).text().split(" ");
parts.splice(1, 1);
$( this ).text(parts.join(" "));
});
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment