This file contains hidden or 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
<?php | |
protected function compareFunction($a, $b){ | |
//any compare function (like strcmp, ...) or treatment we want | |
if ($a->objIntField == $b->objIntField) { | |
return 0; | |
} | |
return ( $a->objIntField > $b->objIntField ); | |
} | |
public function myAction(){ |
This file contains hidden or 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
<?php | |
// 137 seconds => 2min 17s | |
protected function _timeConversion( $seconds ) { | |
$datetime = new DateTime('@' . $seconds, new DateTimeZone('UTC')); | |
$formatted = array( 'd' => $datetime->format('z'), | |
'h' => $datetime->format('G'), | |
'min' => $datetime->format('i'), | |
's' => $datetime->format('s') | |
); |
This file contains hidden or 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
<?php | |
// DISPLAYS COMMENT POST TIME AS "1 year, 1 week ago" or "5 minutes, 7 seconds ago", etc... | |
function time_ago($date,$granularity=2) { | |
$date = strtotime($date); | |
$difference = time() - $date; | |
$periods = array('decade' => 315360000, | |
'year' => 31536000, | |
'month' => 2628000, | |
'week' => 604800, | |
'day' => 86400, |
NewerOlder