Home > php教程 > php手册 > php获取当前日期

php获取当前日期

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:43:35
Original
1459 people have browsed it

// 将目前的时间戳值放入一数组内 $strdate = '2014-02-03'; $desDate = strtotime($strdate); //var_dump($desDate); $timestamp = time(); //echo "\noriginalDate:".date('Y-m-d',time())."\n"; echo "\noriginalDate:".date('Y-m-d',$desDate)."\n"; //$


// 将目前的时间戳值放入一数组内
$strdate = '2014-02-03';
$desDate = strtotime($strdate);
//var_dump($desDate);

$timestamp = time();
//echo "\noriginalDate:".date('Y-m-d',time())."\n";
echo "\noriginalDate:".date('Y-m-d',$desDate)."\n";


//$date_time_array = getdate($timestamp);
$date_time_array = getdate($desDate);
$hours = $date_time_array["hours"];
$minutes = $date_time_array["minutes"];
$seconds = $date_time_array["seconds"];
$month = $date_time_array["mon"];
$day = $date_time_array["mday"];
$year = $date_time_array["year"];
// 用mktime()函数重新产生Unix时间戳值减7天
$timestamp = mktime($hours, $minutes, $seconds, $month, $day-7, $year);
echo "\naddSevenDate:".date('Y-m-d',$timestamp)."\n";


echo "\n------\n";
$yestertime = date ( 'Y-m-d', strtotime("-7 day",$desDate) );
echo "maethod2:".$yestertime;

Related labels:
Statement of this Website
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
Latest Issues
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template