--------------------------------------------------------------------------------
先得到今天的UNIXTIME
然后减去一天或两天的秒数
把减后的UNIXTIME格式化成日期。
--------------------------------------------------------------------------------
CODE:[Copytoclipboard]date_default_timezone_set('Asia/Shanghai');
#昨天
echodate("Y/m/dh:i:s",time()-24*60*60);
echo"
";
#前天
echodate("Y/m/dh:i:s",time()-2*24*60*60);
?>
--------------------------------------------------------------------------------
up
--------------------------------------------------------------------------------
方法有很多种啊,我也介绍一种吧:
date("Y/m/dH:i:s",strtotime("1daysago"));
date("Y/m/dH:i:s",strtotime("2daysago"));
--------------------------------------------------------------------------------
date("Y/m/dH:i:s",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
--------------------------------------------------------------------------------
以前算时间总是很烦人,呵呵,学了了下,下面是下个星期现在的时间。
date_default_timezone_set('Asia/Shanghai');
$tmp=time()+60*60*24*7;
printdate("m/d/YH:i:s",$tmp);
--------------------------------------------------------------------------------
再加一个:
$time_yes=localtime(time()-24*60*60,true);
$time_b_yes=localtime(time()-2*24*60*60,true);
$yesterday=$time_yes['tm_mday'];
$the_day_before_yes=$time_b_yes['tm_mday'];
--------------------------------------------------------------------------------
time()-86400昨天的
--------------------------------------------------------------------------------
高手如云那
--------------------------------------------------------------------------------
QUOTE:
原帖由hutule110于2007-3-2209:51发表
date("Y/m/dH:i:s",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
这个好啊!
--------------------------------------------------------------------------------
//昨天
printdate('Y-m-d',strtotime('-1day'));
//上星期
printdate('Y-m-d',strtotime('-1week'));
//上个月
printdate('Y-m-d',strtotime('-1month'));
//去年
printdate('Y-m-d',strtotime('-1year'));
?>
--------------------------------------------------------------------------------
QUOTE:
原帖由hutule110于2007-3-2209:51发表
date("Y/m/dH:i:s",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
调用函数次数多了些
--------------------------------------------------------------------------------
strtotime得到一个时间戳,然后你自己格式化.
strtotime('yesterday');
strtotime('-2day');