37 lines
No EOL
961 B
PHP
37 lines
No EOL
961 B
PHP
<?php
|
|
|
|
/** This plugin replaces UNIX timestamps with human-readable dates in your local format.
|
|
* Mouse click on the date field reveals timestamp back.
|
|
*
|
|
* @link https://www.adminer.org/plugins/#use
|
|
* @author Anonymous
|
|
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
|
|
*/
|
|
class AdminerReadableDates
|
|
{
|
|
/** @access protected */
|
|
var $prepend;
|
|
|
|
function __construct()
|
|
{
|
|
$this->prepend = <<<EOT
|
|
document.addEventListener('DOMContentLoaded', function(event) {
|
|
var date = new Date();
|
|
var tds = document.querySelectorAll('td[id^="val"]');
|
|
for (var i = 0; i < tds.length; i++) {
|
|
var text = tds[i].innerHTML.trim();
|
|
if (text.match(/^\d{10}$/)) {
|
|
date.setTime(parseInt(text) * 1000);
|
|
tds[i].title = date.toLocaleString();
|
|
}
|
|
}
|
|
});
|
|
EOT;
|
|
}
|
|
|
|
function head()
|
|
{
|
|
echo Adminer\script($this->prepend);
|
|
}
|
|
} |