phpjs
Version:
54 lines (44 loc) • 1.72 kB
Markdown
layout: page
title: "JavaScript getlastmod function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/getlastmod:595
- /functions/view/getlastmod
- /functions/view/595
- /functions/getlastmod:595
- /functions/595
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's getlastmod
{% codeblock info/getlastmod.js lang:js https://raw.github.com/kvz/phpjs/master/functions/info/getlastmod.js raw on github %}
function getlastmod () {
// From: http://phpjs.org/functions
// + original by: Brett Zamir (http://brett-zamir.me)
// % note 1: Will not work on browsers which don't support document.lastModified
// * example 1: getlastmod();
// * returns 1: 1237610043
return new Date(this.window.document.lastModified).getTime() / 1000;
}
{% endcodeblock %}
- [Raw function on GitHub](https://github.com/kvz/phpjs/blob/master/functions/info/getlastmod.js)
Please note that php.js uses JavaScript objects as substitutes for PHP arrays, they are
the closest match to this hashtable-like data structure.
Please also note that php.js offers community built functions and goes by the
[McDonald's Theory](https://medium.com/what-i-learned-building/9216e1c9da7d). We'll put online
functions that are far from perfect, in the hopes to spark better contributions.
Do you have one? Then please just:
- [Edit on GitHub](https://github.com/kvz/phpjs/edit/master/functions/info/getlastmod.js)
### Example 1
This code
{% codeblock lang:js example %}
getlastmod();
{% endcodeblock %}
Should return
{% codeblock lang:js returns %}
1237610043
{% endcodeblock %}
### Other PHP functions in the info extension
{% render_partial _includes/custom/info.html %}