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
/*********************************************************** | |
******* SIMPLE TEST **/ | |
class A { | |
function t() { | |
echo get_calling_class(); | |
} | |
} | |
class B { |
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
<?php | |
$dt_end = new DateTime('December 3, 2016 2:00 PM'); | |
$remain = $dt_end->diff(new DateTime()); | |
echo $remain->d . ' days and ' . $remain->h . ' hours'; |
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
<?php | |
function _ago($tm,$rcs = 0) { | |
$cur_tm = time(); $dif = $cur_tm-$tm; | |
$pds = array('second','minute','hour','day','week','month','year','decade'); | |
$lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600); | |
for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]); | |
$no = floor($no); if($no <> 1) $pds[$v] .='s'; $x=sprintf("%d %s ",$no,$pds[$v]); | |
if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm); |
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
<?php | |
$start_date = new DateTime('2010-10-01'); | |
$end_date = new DateTime('2010-10-05'); | |
$period = new DatePeriod( | |
$start_date, // 1st PARAM: start date | |
new DateInterval('P1D'), // 2nd PARAM: interval (1 day interval in this case) | |
$end_date, // 3rd PARAM: end date | |
DatePeriod::EXCLUDE_START_DATE // 4th PARAM (optional): self-explanatory |
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
<?php | |
function age($date){ | |
$time = strtotime($date); | |
if($time === false){ | |
return ''; | |
} | |
$year_diff = ''; | |
$date = date('Y-m-d', $time); |
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
<?php | |
if(strtotime(dateString) > time()) { | |
# date is in the future | |
} | |
if(strtotime(dateString) < time()) { | |
# date is in the past | |
} |
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
<?php | |
function dateDiff($date1, $date2){ | |
$datetime1 = new DateTime($date1); | |
$datetime2 = new DateTime($date2); | |
$interval = $datetime1->diff($datetime2); | |
return $interval->format('%H:%I'); | |
} |
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
<?php | |
function convertToHoursMins($time, $format = '%02d:%02d') { | |
if ($time < 1) { | |
return; | |
} | |
$hours = floor($time / 60); | |
$minutes = ($time % 60); | |
return sprintf($format, $hours, $minutes); | |
} |
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
<?php | |
function weeknumber($ddate){ | |
$date = new DateTime($ddate); | |
return $date->format("W"); | |
} |
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
<?php | |
$originalDate = "2010-03-21"; | |
$newDate = date("d-m-Y", strtotime($originalDate)); |
NewerOlder