How to file rename in php?
Examples :
<?php
rename ("oldFile.php", "NewFile.php");
?>
First parameters is existence file and second parameter is your desire file name.
Examples :
rename ("oldFile.php", "NewFile.php");?>
First parameters is existence file and second parameter is your desire file name.
$shiftInTime = strtotime($shiftInTime);
$punchInTime = strtotime($punchInTime);
if($shiftInTime <= $punchInTime)
{ Echo $present = ‘present’;}
Else
{ Echo “Absence”;
}
$punchInTime = ’09:00:00′;
$graceTime = ’30′;
$mytime = ($punchInTime = date(“H:i:s”, strtotime( “$punchInTime + $graceTime mins”)));
Echo $mytime;
$d = ’2011-05-23′;
echo $strToTimeToOrginalDate = date(‘Y-m-d’, strtotime($d));
// an START time value
$start = ’09:00′;
// an END time value
$end = ’10:30′;
// what is the time difference between $end and $start?
if( $diff=@get_time_difference($start, $end) )
{
echo “Hours: ” .
sprintf( ‘%02d:%02d’, $diff['hours'], $diff['minutes'] );
}
else
{
echo “Hours: Error”;
}
//Call function for time diff
function get_time_difference( $start, $end )
{ $uts['start'] = strtotime( $start );
$uts['end'] = strtotime( $end );
if( $uts['start']!==-1 && $uts['end']!==-1 )
{
if( $uts['end'] >= $uts['start'] )
{
$diff = $uts['end'] – $uts['start'];
if( $days=intval((floor($diff/86400))) )
$diff = $diff % 86400;
if( $hours=intval((floor($diff/3600))) )
$diff = $diff % 3600;
if( $minutes=intval((floor($diff/60))) )
$diff = $diff % 60;
$diff = intval( $diff );
return( array(‘days’=>$days, ‘hours’=>$hours, ‘minutes’=>$minutes, ‘seconds’=>$diff) );
}
else
{
trigger_error( “Ending date/time is earlier than the start date/time”, E_USER_WARNING );
}
}
else
{
trigger_error( “Invalid date/time data detected”, E_USER_WARNING );
}
return( false );
}
$tuesday = strtotime(‘last Tuesday’);
echo date(“Y-m-d”, $tuesday) ;
$mydate = ‘2011-02-04’;
//Get First Day date from given date
echo date(“Y-m-1″, strtotime($mydate) ) ;
//Get Last Day date from given date
echo date(“Y-m-t”, strtotime($mydate) ) ;
$date1 = “2011-03-23″;
$date2 = date(“Y-m-d”);
function twoDateCompareEqualOrNot($date1,$date2)
{
$date1 = strtotime($date1);
$date2 = strtotime($date2);
if ($date1 == $date2) {
return true;
}
else {
return false;
}
}
$dates_array = dates_inbetween(’2011-03-1′, ’2011-03-22′);
function dates_inbetween($date1, $date2){
$day = 60*60*24;
$date1 = strtotime($date1);
$date2 = strtotime($date2);
$days_diff = round(($date2 – $date1)/$day); // Unix time difference devided by 1 day to get total days in between
$dates_array = array();
$dates_array[] = date(‘Y-m-d’,$date1);
for($x = 1; $x < $days_diff; $x++){
$dates_array[] = date('Y-m-d',($date1+($day*$x)));
}
$dates_array[] = date('Y-m-d',$date2);
return $dates_array;
}