Home  >  Article  >  Backend Development  >  Examples of dynamic web page production technology PHP processing time_PHP tutorial

Examples of dynamic web page production technology PHP processing time_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:05:34800browse

/**
* Convert to UNIX timestamp
*/
function gettime($d) {
if(is_numeric($d))
return $d;
else {
if(! is_string($d)) return 0;
if(ereg(":",$d)) {
$buf = split(" ",$d);
$year = split("[-/]",$buf[0]);
$hour = split(":",$buf[1]);
if(eregi("pm",$buf[2]))
$hour[0] = 12;
return mktime($hour[0],$hour[1],$hour[2],$year[1],$year[2],$year[0]);
}else {
$year = split("[-/]",$d);
return mktime(0,0,0,$year[1],$year[2],$year[0]);
}
}
}

/**
*
* DateAdd(interval,number,date)
* Returns the date to which the specified time interval has been added.
* Inetrval is a string expression representing the time interval to be added, such as minutes or days
* number is a numerical expression representing the number of time intervals to be added
* Date represents the date
*
* Interval (time interval string expression) can be any of the following values:
* yyyy year year
* q Quarter quarter
* m Month month
* y Day of year Number of year
* d Day
* w Weekday Number of days in a week
* ww Week of year Week
* h Hour hour
* n Minute minute
* s Second second
* The functions of w, y and d are exactly the same, that is, add one day to the current date, q adds 3 months, and ww adds 7 days.
*/
function DateAdd($interval, $number, $date) {
$date = gettime($date);
$date_time_array = getdate($date);
$hours = $date_time_array["hours"];
$minutes = $date_time_array["minutes"];
$seconds = $date_time_array["seconds"];
$month = $date_time_array["mon"];


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445102.htmlTechArticle? /*** Convert to UNIX timestamp*/ function gettime($d) { if(is_numeric($d)) return $d; else { if(! is_string($d)) return 0; if(ereg(:,$d)) { $buf = split( ,$d); $year = split([-/],...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn