Skip to content

Instantly share code, notes, and snippets.

Created April 7, 2016 08:52
Show Gist options
  • Select an option

  • Save anonymous/74c5cd7c1a9061728e5ff347236344e4 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/74c5cd7c1a9061728e5ff347236344e4 to your computer and use it in GitHub Desktop.
JS Bin [add your bin description] // source http://jsbin.com/maravu
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
function daysThisMonth() {
var date = new Date(),
y = date.getFullYear(),
m = date.getMonth(),
start = new Date(y, m, 1),
end = new Date(y, m + 1, 1);
return (end - start) / (1000 * 60 * 60 * 24);
}
function daysInMonth(y, m) {
var start = new Date(y, m - 1, 1),
end = new Date(y, m, 1);
return (end - start) / (1000 * 60 * 60 * 24);
}
console.log(daysThisMonth());
console.log(daysInMonth(2016,4));
</script>
<script id="jsbin-source-javascript" type="text/javascript">
function daysThisMonth() {
var date = new Date(),
y = date.getFullYear(),
m = date.getMonth(),
start = new Date(y, m, 1),
end = new Date(y, m + 1, 1);
return (end - start) / (1000 * 60 * 60 * 24);
}
function daysInMonth(y, m) {
var start = new Date(y, m - 1, 1),
end = new Date(y, m, 1);
return (end - start) / (1000 * 60 * 60 * 24);
}
console.log(daysThisMonth());
console.log(daysInMonth(2016,4));</script></body>
</html>
function daysThisMonth() {
var date = new Date(),
y = date.getFullYear(),
m = date.getMonth(),
start = new Date(y, m, 1),
end = new Date(y, m + 1, 1);
return (end - start) / (1000 * 60 * 60 * 24);
}
function daysInMonth(y, m) {
var start = new Date(y, m - 1, 1),
end = new Date(y, m, 1);
return (end - start) / (1000 * 60 * 60 * 24);
}
console.log(daysThisMonth());
console.log(daysInMonth(2016,4));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment