SEO対策

Php日期加减函数

php在做日期加减的时候非常麻烦,没有现成的函数,我做了一个。解决了2009-05-31加上一个月会变2009-06-31,这样就错了,6月没有31号,就变成了7月一号了!我的函数在月分加减上没有问题了。



function my_date_add($opt,$time,$num){

  $year = date('Y',strtotime($time));
  $month = date('m',strtotime($time));
  $day = date('d',strtotime($time));
  $last_day = date('t',strtotime($time));

  if($opt=='y'){
    $year = $year + $num;
  } else if($opt=='d'){
    $day = $day + $num;
  } else if($opt=='m'){
    $month = $month + $num;
    if($day == $last_day){//如果是最后一天的话
      $day = date('t',strtotime("{$year}-{$month}-01"));
    }
  } else {
    return $time;
  }

  return date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
}

2009-07-01 16:00:36 のブログ記事
twitter

等待ipad 4.2破解

开始看雷蒙德·卡佛的短篇集。。。

等待touch3破解,geohot is real man

cts-v这汽车真是太猛了!!!!

终于拿到了签证.....

雅歌塔克里斯多夫的《第三谎言》,已经看完了

两个前轮胎换成了普利司通的了,后面两个什么时候才能换呢????

在女朋友的允许下我终于买了ndsi

It was the best of times. It was the worst of times --《A Tale of Two Cities》

《神经浪游者》阅读到第18页。。。。没时间看了。。。可能再也看不完了

Philip Kindred Dick的《Minority Report》已经看完了。。。。。

Rss Space