Created
June 16, 2011 14:22
-
-
Save pironic/1029308 to your computer and use it in GitHub Desktop.
Overviewer Timestamp bottom right
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div align="center" style="font-size:70%; position:relative; top:5px; left:5px; background-color:grey;opacity:0.8;">Last Update Finished <?php echo writhem_time(GetCorrectMTime(@'updated.json')); ?></div> | |
<?php | |
function GetCorrectMTime($filePath) | |
{ | |
$time = filemtime($filePath); | |
$isDST = (date('I', $time) == 1); | |
$systemDST = (date('I') == 1); | |
$adjustment = 0; | |
if($isDST == false && $systemDST == true) | |
$adjustment = 3600; | |
else if($isDST == true && $systemDST == false) | |
$adjustment = -3600; | |
else | |
$adjustment = 0; | |
return ($time + $adjustment); | |
} | |
function writhem_time($td) | |
{ | |
if ((mktime(0, 0, 0, date("m",$td) , date("d",$td), date("Y",$td)) >= mktime(0, 0, 0, date("m"), date("d")-6, date("Y"))) && (mktime(0, 0, 0, date("m",$td) , date("d",$td), date("Y",$td)) <= mktime(0, 0, 0, date("m"), date("d")-2, date("Y")))) { | |
$ts = 'Last ' . date('D @ g:ia',$td); // Past: Last Mon @ 3:14pm | |
} elseif ((mktime(0, 0, 0, date("m",$td) , date("d",$td), date("Y",$td)) >= mktime(0, 0, 0, date("m"), date("d")+6, date("Y"))) && (mktime(0, 0, 0, date("m",$td) , date("d",$td), date("Y",$td)) <= mktime(0, 0, 0, date("m"), date("d")+2, date("Y")))) { | |
$ts = 'This ' . date('D',$td) . ' (' . date('jS) @ g:ia',$td); // Future: Mon @ 3:14pm | |
} elseif (date('Y',$td) == date('Y')) { | |
if (date('m',$td) == date('m')) { | |
if (date('d',$td) == date('d')) { | |
$ts = "Today @ " . date('g:i a',$td); // Today @ 3:14pm | |
} elseif (mktime(0, 0, 0, date("m",$td) , date("d",$td), date("Y",$td)) == mktime(0, 0, 0, date("m"), date("d")+1, date("Y"))) { | |
$ts = "Tomorrow @ " . date('g:ia',$td); // Future: Tomorrow @ 3:14pm | |
} elseif (mktime(0, 0, 0, date("m",$td) , date("d",$td), date("Y",$td)) == mktime(0, 0, 0, date("m"), date("d")-1, date("Y"))) { | |
$ts = "Yesterday @ " . date('g:ia',$td); // Past: Yesterday @ 3:14pm | |
} elseif (date('U',$td) > date('U')) { | |
$ts = date('M jS @ g:ia',$td); // Future, not this week, same month : Mar 13th @ 3:14pm | |
} else { | |
$ts = date('M jS',$td); // Past, not this week, same month : Mar 13th | |
} | |
} elseif (date('U',$td) > date('U')) { | |
$ts = date('M jS @ g:ia',$td); // Future, not this month : Mar 13th @ 3:14pm | |
} else { | |
$ts = date('M jS',$td); // Past, not this month : Mar 13th | |
} | |
} elseif (date('U',$td) > date('U')) { | |
$ts = date('M jS \'y @ g:ia',$td); // Future, Not this year : Mar 13th '10 @ 3:14pm | |
} else { | |
$ts = date('M jS \'y', $td); // Past, not this year : Mar 13th '10 | |
} | |
return $ts; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment