Skip to content

Instantly share code, notes, and snippets.

@mluerig
Last active January 19, 2022 15:44
Show Gist options
  • Save mluerig/6a1b89ac2b0c4ef2fb72c7131a0b89f7 to your computer and use it in GitHub Desktop.
Save mluerig/6a1b89ac2b0c4ef2fb72c7131a0b89f7 to your computer and use it in GitHub Desktop.
getting the latest mod date-time for websites
repo_api_link = "https://api.github.com/repos/phenopype/phenopype-lander/commits";
function ModifiedDateTime() {
fetch(repo_api_link).then((response) => {
return response.json();
})
.then((commits) => {
var dat = commits[0]['commit']['committer']['date'];
document.getElementById('last-modified-datetime').textContent = dat.slice(0,10) + " " + dat.slice(11,19) ;
});
}
ModifiedDateTime()
function ModifiedDate() {
fetch(repo_api_link).then((response) => {
return response.json();
})
.then((commits) => {
var dat = commits[0]['commit']['committer']['date'];
document.getElementById('last-modified-date').textContent = dat.slice(0,10);
});
}
ModifiedDate()
function ModifiedYear() {
fetch(repo_api_link).then((response) => {
return response.json();
})
.then((commits) => {
var dat = commits[0]['commit']['committer']['date'];
document.getElementById('last-modified-year').textContent = dat.slice(0,4);
});
}
ModifiedYear()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment