Skip to content

Instantly share code, notes, and snippets.

@kureikei
Last active Aug 29, 2015
Embed
What would you like to do?
var t = new Date();
var count = new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
var offset = new Date(t.getFullYear(), t.getMonth(), 1).getDay();
var body = "";
for (var i = 0; i < offset; i++) {
body += " ";
}
for (var i = 1; i <= count; i++) {
body += (" " + i).slice(-2);
body += ((i + offset) % 7 == 0) ? "\n" : " ";
}
console.log(body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment