Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 13:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
はてなブログで日付に曜日を付けるやつ (1行版もあります。)
datetimeEle = document.querySelectorAll('.date [datetime]');
for (var i = 0; i < datetimeEle.length; i++){
function DateToWeek(day){
if(typeof day === "undefined"){return ""}
//day = day.substr(0,10);
var d = new Date(day);
if(typeof d === "undefined" || isNaN( d ) ){return ""}
var w = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
var w = ["日","月","火","水","木","金","土"];
var el = document.createElement("span");
var str = document.createTextNode(w[d.getDay()]);
el.setAttribute("class", "date-week date-week-" +;
return el;
Copy link

niyari commented Mar 4, 2014


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment