Posted By

Leech on 10/12/08


Tagged

php month calendar days


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jamesming
luman


Get days in month


 / Published in: PHP
 

URL: http://feeds.cristalab.com/~r/clab/~3/409808339/como-obtener-el-total-de-dias-en-un-mes-en-php.html

  1. <?
  2. function getMonthDays($Month, $Year)
  3. {
  4. //Si la extensión que mencioné está instalada, usamos esa.
  5. if( is_callable("cal_days_in_month"))
  6. {
  7. return cal_days_in_month(CAL_GREGORIAN, $Month, $Year);
  8. }
  9. else
  10. {
  11. //Lo hacemos a mi manera.
  12. return date("d",mktime(0,0,0,$Month+1,0,$Year));
  13. }
  14. }
  15.  
  16. //Obtenemos la cantidad de días que tiene septiembre del 2008
  17. echo getMonthDays(9, 2008);
  18. ?>

Report this snippet  

You need to login to post a comment.