Your Ad Here

Posted By

sekihin on 04/28/09


Tagged

php date


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Dean_IconWeb
fackz
BrianCoyDesign


get previous month


 / Published in: PHP
 

  1. /*
  2. ����������������
  3. ���
  4.   $date æ�¥ä»�ã��示ã��æ��å­�å��(YYYY/MM/DD)ã��æ��å®�ã��ã�¾ã��
  5. ����
  6.   æ��å®�ã��ã��æ�¥ã�®å��æ��ã��示ã��æ�°å�¤
  7. */
  8. function get_previous_month($date) {
  9. $date = str_replace("/", "-", $date);
  10. $year=date("Y",strtotime($date));
  11. $month=date("n",strtotime($date)) - 1;
  12. if ($month == 0) {
  13. $month = 12;
  14. $year = $year - 1;
  15. }
  16. return date("Y/m/d", mktime(0, 0, 0, $month, 1, $year));
  17. }

Report this snippet  

You need to login to post a comment.