Below are also some examples of using date functions using PHP
public function subMonthFromDate($timeStamp, $totalMonths=1){//this function is used to get the start of the month by setting "$thePHPDate['mday'] =1" // You can Subtract as many months as you want. mktime will accumulate to the next year. $thePHPDate = getdate($timeStamp); // Covert to Array $thePHPDate['mon'] = $thePHPDate['mon']-$totalMonths; // Subtract from Month $thePHPDate['mday'] =1;//this is intentionally set to one to get the first day of the month $timeStamp = mktime($thePHPDate['hours'], $thePHPDate['minutes'], $thePHPDate['seconds'], $thePHPDate['mon'], $thePHPDate['mday'], $thePHPDate['year']); // Convert back to timestamp return $timeStamp; }
public function subDaysFromDate($timeStamp, $totalDay=1){//subtraction days from provided time stamp
$thePHPDate = getdate($timeStamp); // Covert to Array $thePHPDate['mday'] = $thePHPDate['mday']-$totalDay; // Subtract from Month $timeStamp = mktime($thePHPDate['hours'], $thePHPDate['minutes'], $thePHPDate['seconds'], $thePHPDate['mon'], $thePHPDate['mday'], $thePHPDate['year']); // Convert back to timestamp return $timeStamp; }
public function GetCurrentWeekStart($timeStamp){//logic implemented for current week(first day of the week)--rajesh // You can Subtract as many days as you want. mktime will accumulate to the next month / year. $thePHPDate = getdate($timeStamp);
2 comments:
Below are also some examples of using date functions using PHP
public function subMonthFromDate($timeStamp, $totalMonths=1){//this function is used to get the start of the month by setting "$thePHPDate['mday'] =1"
// You can Subtract as many months as you want. mktime will accumulate to the next year.
$thePHPDate = getdate($timeStamp); // Covert to Array
$thePHPDate['mon'] = $thePHPDate['mon']-$totalMonths; // Subtract from Month
$thePHPDate['mday'] =1;//this is intentionally set to one to get the first day of the month
$timeStamp = mktime($thePHPDate['hours'], $thePHPDate['minutes'], $thePHPDate['seconds'], $thePHPDate['mon'], $thePHPDate['mday'], $thePHPDate['year']); // Convert back to timestamp
return $timeStamp;
}
public function subDaysFromDate($timeStamp, $totalDay=1){//subtraction days from provided time stamp
$thePHPDate = getdate($timeStamp); // Covert to Array
$thePHPDate['mday'] = $thePHPDate['mday']-$totalDay; // Subtract from Month
$timeStamp = mktime($thePHPDate['hours'], $thePHPDate['minutes'], $thePHPDate['seconds'], $thePHPDate['mon'], $thePHPDate['mday'], $thePHPDate['year']); // Convert back to timestamp
return $timeStamp;
}
public function GetCurrentWeekStart($timeStamp){//logic implemented for current week(first day of the week)--rajesh
// You can Subtract as many days as you want. mktime will accumulate to the next month / year.
$thePHPDate = getdate($timeStamp);
$thePHPDate['mday'] = $thePHPDate['mday']-($thePHPDate['wday']-1);//start date
$timeStamp = mktime($thePHPDate['hours'], $thePHPDate['minutes'], $thePHPDate['seconds'], $thePHPDate['mon'], $thePHPDate['mday'], $thePHPDate['year']);
return $timeStamp;
}
i want to convert the date into the same format of getdate() to have comparision with the date passed from front.? how can i do that..?
product photographer miami
Post a Comment