Ver Mensaje Individual
  #27 (permalink)  
Antiguo 05/01/2012, 13:15
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: cambiar dias de la semana a español

vamos a ver

Código PHP:
Ver original
  1. <?php
  2.  
  3. include('admin/dbconn.php');
  4. include('functions/functions.php');
  5.  
  6. date_default_timezone_set('Europe/Madrid');
  7. $dias = array('Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sábado');
  8. $meses = array('Diciembre','Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre');
  9.  
  10. $type = CAL_GREGORIAN;
  11.  
  12. if(isset($_GET['month'])) $month = trim(stripslashes(strip_tags($_GET['month'])));
  13. if(isset($_GET['year'])) $year = trim(stripslashes(strip_tags($_GET['year'])));
  14.  
  15. if(!isset($_GET['month']) || !is_numeric($_GET['month'])) $month = date('n'); // Month ID, 1 through to 12.
  16. if(!isset($_GET['year']) || !is_numeric($_GET['year'])) $year = date('Y'); // Year in 4 digit 2009 format.
  17.  
  18. $today = date('Y/n/d');
  19.  
  20. $day_count = cal_days_in_month($type, $month, $year); // Get the amount of days in the chosen month to give to our function.
  21.  
  22. echo "<div id='calendar'>";
  23. echo "<div id='calendar_wrap'>";
  24.  
  25. // Function for year change. //
  26.  
  27. $last_month = $month - 1;
  28. $next_month = $month + 1;
  29.  
  30. $last_year = $year - 1;
  31. $next_year = $year + 1;
  32.  
  33. if($month == 12):
  34. $change_year = $year;
  35. $change_month = $last_month;
  36. elseif($month == 1):
  37. $change_year = $last_year;
  38. $change_month = '12';
  39. else:
  40. $change_year = $year;
  41. $change_month = $last_month;
  42. endif;
  43.  
  44. if($month == 1):
  45. $change_year_next = $year;
  46. $change_month_next = $next_month;
  47. elseif($month == 12):
  48. $change_year_next = $next_year;
  49. $change_month_next = '1';
  50. else:
  51. $change_year_next = $year;
  52. $change_month_next = $next_month;
  53. endif;
  54.  
  55. echo "<div class='title_bar'>";
  56.  
  57. echo "<a href='".$_SERVER['PHP_SELF']."?month=". $change_month ."&year=". $change_year ."'><div class='previous'></div></a>";
  58. echo "<a href='".$_SERVER['PHP_SELF']."?month=". $change_month_next ."&year=". $change_year_next ."'><div class='next'></div></a>";
  59. echo "<h2 class='month'>". $meses[date('n', mktime(0,0,0,$month,1))] . "&nbsp;" . $year . "</h2>";
  60.  
  61.  
  62. echo "</div>";
  63.  
  64. /* Previous Month */
  65.  
  66. $first_day = date('N', mktime(0,0,0,$month,1,$year));
  67.  
  68. if ( ($first_day_of_week=='Monday' && $first_day != 1) || ($first_day_of_week=='Sunday' && $first_day != 7) ) :
  69.  
  70. $last_month_day_count = cal_days_in_month($type, $change_month, $change_year);
  71.  
  72. if ($first_day_of_week=='Monday') :
  73.  
  74.  
  75.  
  76. if ( 'Monday' == date('l', mktime(0,0,0,$change_month,$last_month_day_count,$change_year)) ) :
  77. $final_day = date('j', mktime(0,0,0,$change_month,$last_month_day_count,$change_year));
  78. else :
  79. $final_day = date('j', strtotime('last Monday', mktime(0,0,0,$change_month,$last_month_day_count,$change_year) ) );
  80. endif;
  81. else :
  82. if ( 'Sunday' == date('l', mktime(0,0,0,$change_month,$last_month_day_count,$change_year)) ) :
  83. $final_day = date('j', mktime(0,0,0,$change_month,$last_month_day_count,$change_year));
  84. else :
  85. $final_day = date('j', strtotime('last Sunday', mktime(0,0,0,$change_month,$last_month_day_count,$change_year) ) );
  86. endif;
  87. endif;
  88.  
  89. // Not a monday so fill the gap
  90. for($i=$final_day; $i<=$last_month_day_count; $i++):
  91.  
  92. $date = $change_year.'/'.$change_month.'/'.$i;
  93.  
  94. $get_name = $dias[date('w', strtotime($date))];
  95. $month_name = $meses[date('n', strtotime($date))];
  96. $day_name = substr($get_name, 0, 3); // Trim day name to 3 chars
  97.  
  98. $count = count_events($i,$change_month,$change_year);
  99. if($count >= 1)
  100. echo "<a href='day_view.php?day=$i&month=$change_month&year =$change_year' title='$i $month_name' rel='day_view'>";
  101. echo "<div class='cal_day last_month'>"; // Calendar Day
  102.  
  103. echo "<div class='day_heading'>" . $day_name . "</div>";
  104.  
  105. if($count >= 1) echo "<div class='day_count'><span class='event'>" . $count . "</span></div>";
  106.  
  107. if($today == $date):
  108. echo "<div class='day_number today'>" . $i . "</div>";
  109. else:
  110. echo "<div class='day_number'>" . $i . "</div>";
  111. endif;
  112.  
  113. echo "</div>";
  114. echo "</a>";
  115.  
  116. endfor;
  117.  
  118. endif;
  119.  
  120. /* Current Month */
  121.  
  122. for($i=1; $i<= $day_count; $i++): // Start of for $i
  123.  
  124. $date = $year.'/'.$month.'/'.$i;
  125.  
  126. $get_name = $dias[date('w', strtotime($date))];
  127. $month_name = $meses[date('n', strtotime($date))];
  128. $day_name = substr($get_name, 0, 3); // Trim day name to 3 chars
  129.  
  130. $count = count_events($i,$month,$year);
  131. if($count >= 1)
  132. echo "<a href='day_view.php?day=$i&month=$month&year=$year' title='$i $month_name' rel='day_view'>";
  133. echo "<div class='cal_day'>"; // Calendar Day
  134.  
  135. echo "<div class='day_heading'>" . $day_name . "</div>";
  136.  
  137. if($count >= 1) echo "<div class='day_count'><span class='event'>" . $count . "</span></div>";
  138.  
  139. if($today == $date):
  140. echo "<div class='day_number today'>" . $i . "</div>";
  141. else:
  142. echo "<div class='day_number'>" . $i . "</div>";
  143. endif;
  144.  
  145. echo "</div>";
  146. echo "</a>";
  147.  
  148. endfor; // EOF for $i
  149.  
  150. /* Next Month */
  151.  
  152. $last_day = date('N', mktime(0,0,0,$month,$day_count,$year));
  153.  
  154. if ( ($first_day_of_week=='Monday' && $last_day != 7) || ($first_day_of_week=='Sunday' && $last_day != 1) ) :
  155.  
  156. if ($first_day_of_week=='Monday') :
  157. if ( 'Sunday' == date('l', mktime(0,0,0,$change_month_next,1,$change_year_next)) ) :
  158. $first_day = date('j', mktime(0,0,0,$change_month_next,1,$change_year_next));
  159. else :
  160. $first_day = date('j', strtotime('first Sunday', mktime(0,0,0,$change_month_next,1,$change_year_next) ) );
  161. endif;
  162. else :
  163. if ( 'Saturday' == date('l', mktime(0,0,0,$change_month_next,1,$change_year_next)) ) :
  164. $first_day = date('j', mktime(0,0,0,$change_month_next,1,$change_year_next));
  165. else :
  166. $first_day = date('j', strtotime('first Saturday', mktime(0,0,0,$change_month_next,1,$change_year_next) ) );
  167. endif;
  168. endif;
  169.  
  170.  
  171. // Not a monday so fill the gap
  172. for($i=1; $i<=$first_day; $i++):
  173.  
  174. $date = $change_year_next.'/'.$change_month_next.'/'.$i;
  175.  
  176. $get_name = $dias[date('w', strtotime($date))];
  177. $month_name = $meses[date('n', strtotime($date))];
  178. $day_name = substr($get_name, 0, 3); // Trim day name to 3 chars
  179.  
  180. $count = count_events($i,$change_month_next,$change_year_next);
  181. if($count >= 1)
  182. echo "<a href='day_view.php?date=$i&month=$change_month_nex t&year=$change_year_next' title='$i $month_name' rel='day_view'>";
  183. echo "<div class='cal_day next_month'>"; // Calendar Day
  184.  
  185. echo "<div class='day_heading'>" . $day_name . "</div>";
  186.  
  187. if($count >= 1) echo "<div class='day_count'><span class='event'>" . $count . "</span></div>";
  188.  
  189. if($today == $date):
  190. echo "<div class='day_number today'>" . $i . "</div>";
  191. else:
  192. echo "<div class='day_number'>" . $i . "</div>";
  193. endif;
  194.  
  195. echo "</div>";
  196. echo "</a>";
  197.  
  198. endfor;
  199.  
  200. endif;
  201.  
  202. echo "</div>";
  203. ?>

y tienes mal exo algo que el mes 12 arriba del calendario no lo muestra