public function monthOptions() { $format = (string) $this->getParameter('format'); // number, short, long $selected = (int) $this->getParameter('selected'); $formats = array('number', 'short', 'long'); if (!in_array($format, $formats)) { $format = 'number'; } if ($format != 'number') { $cal = cal_info(CAL_GREGORIAN); if ($format == 'short') { $months = $cal['abbrevmonths']; } else { $months = $cal['months']; } } else { $months = array(); for ($i = 1; $i <= 12; $i++) { $months[$i] = str_pad($i, 2, '0', STR_PAD_LEFT); } } $options = ''; for ($i = 1; $i <= 12; $i++) { $ipad = str_pad($i, 2, '0', STR_PAD_LEFT); if ($selected == $i) { $options .= '<option value="' . $ipad . '" selected>' . $months[$i] . '</option>'; } else { $options .= '<option value="' . $ipad . '">' . $months[$i] . '</option>'; } } return $options; }
/** * @param Application $app * @param int $idArticulo * * @return JsonResponse */ public function verAjax(Application $app, $idArticulo) { $comentarioModelo = new ComentarioModelo($app['db']); $comentarios = $comentarioModelo->getComentariosArticulo($idArticulo); $mesesIngles = cal_info(0); $mesesEspanol = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'); foreach ($comentarios as $index => $comentario) { $fecha = date('d-F-Y | h:m:s A', strtotime($comentario['fecha'])); $fecha = str_replace('-', ' de ', $fecha); $fecha = str_replace($mesesIngles['months'], $mesesEspanol, $fecha); $comentarios[$index]['fecha'] = $fecha; } return new JsonResponse($comentarios); }
/** * @param Request $request * @param Application $app * @param int $id * * @return RedirectResponse */ public function verNoticiasJson(Request $request, Application $app) { $categoriaModelo = new Categoria($app['db']); $categorias = $categoriaModelo->getTodo(array(), array(), "WHERE id > 1"); $articuloModelo = new Articulo($app['db']); $articulos = $articuloModelo->getTodo(); $mesesIngles = cal_info(0); $mesesEspanol = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'); foreach ($articulos as $index => $articulo) { # Poner sólo la primera en mayúscula el título $articulos[$index]['titulo'] = strtolower($articulo['titulo']); $articulos[$index]['titulo'][0] = strtoupper($articulo['titulo'][0]); $fechaPublicacion = date('d-F-Y | h:m A', strtotime($articulo['fecha_pub'])); $fechaPublicacion = str_replace('-', ' de ', $fechaPublicacion); $fechaPublicacion = str_replace($mesesIngles['months'], $mesesEspanol, $fechaPublicacion); $articulos[$index]['fecha_pub'] = $fechaPublicacion; } return new JsonResponse(array("articulos" => $articulos, 'categorias' => $categorias)); }
/** * * @param Request $request * @param Application $app * @param int $idArticulo * * @return mixed */ public function imprimir(Request $request, Application $app, $idArticulo) { $articuloModel = new Articulo($app['db']); $articulo = $articuloModel->getArticuloYEtiquetas($idArticulo); $mesesIngles = cal_info(0); $mesesEspanol = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'); if (empty($articulo)) { $app['session']->getFlashBag()->add('warning', array('message' => '¡Artículo no encontrado!')); return $app->redirect($app['url_generator']->generate('home')); } else { $fechaPublicacion = date('d-F-Y | h:m A', strtotime($articulo['fecha_pub'])); $fechaPublicacion = str_replace('-', ' de ', $fechaPublicacion); $fechaPublicacion = str_replace($mesesIngles['months'], $mesesEspanol, $fechaPublicacion); $imagenModel = new Imagen($app['db']); $articulo['imagen'] = $imagenModel->getImagenByUrl($articulo['imagen']); $articulo['fecha_pub'] = $fechaPublicacion; } return $app['twig']->render('frontend/imprimir.html.twig', array("articulo" => $articulo)); }
/** * @param Application $app * * @return mixed */ public function index(Application $app) { $categoriaModelo = new Categoria($app['db']); $categorias = $categoriaModelo->getTodo(array(), array(), "WHERE id > 1"); $articuloModelo = new Articulo($app['db']); $articulos = $articuloModelo->getTodo(); $mesesIngles = cal_info(0); $mesesEspanol = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'); foreach ($articulos as $index => $articulo) { # Poner sólo la primera en mayúscula el título // $articulos[$index]['titulo'] = strtolower($articulo['titulo']); // $articulos[$index]['titulo'][0] = strtoupper($articulo['titulo'][0]); $fechaPublicacion = date('d-F-Y | h:m A', strtotime($articulo['fecha_pub'])); $fechaPublicacion = str_replace('-', ' de ', $fechaPublicacion); $fechaPublicacion = str_replace($mesesIngles['months'], $mesesEspanol, $fechaPublicacion); $articulos[$index]['fecha_pub'] = $fechaPublicacion; } $menuModelo = new Menu($app['db']); $menuItems = $menuModelo->getItems(); return $app['twig']->render('frontend/index.html.twig', array('articulos' => $articulos, 'categorias' => $categorias, 'menu_items' => $menuItems)); }
<?php require "connection.php"; $id = $_GET['id']; $sql = "SELECT * FROM birthdays WHERE id='{$id}'"; $result = mysqli_query($conn, $sql); $output = mysqli_fetch_all($result); $oldname = $output[0][1]; $oldday = $output[0][2]; $oldmonth = $output[0][3]; $oldyear = $output[0][4]; $info = cal_info(0); $months = $info['months']; $montha = $months[$_GET['month']]; ?> <!DOCTYPE html> <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="../css/main.css"> </head> <body id="add"> <?php require 'head.php'; ?> <header> <img id="fireplace" src="../images/fireplace3.gif"> </header> <h1>Change</h1> <form action="confirmedit.php?id=<?php echo $id;
/** * Return short names for the months of the specific calendar. * * @see \cal_info() * @param integer $calendarId Calendar ID (according to PHP cal_info) * @return array Array of month short names */ public static function getCalendarShortMonths($calendarId = 0) { if (!isset(self::$calendarShortMonths[$calendarId])) { $calendar_info = cal_info($calendarId); self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; } return self::$calendarShortMonths[$calendarId]; }
</div> </div> <div class="row"> <div class="col-md-3"> <?php echo $form->field($model, 'gender')->dropDownList(['male' => 'Male', 'female' => 'Female'], ['prompt' => 'Gender']); ?> </div> <div class="col-sm-8 col-sm-offset-1"> <label for="">Birthdate</label> <div class="row"> <div class="col-md-3"> <?php $months = cal_info(0); echo $form->field($model, 'dob_month')->dropDownList($months['months'], ['prompt' => 'Month'])->label(false); ?> </div> <div class="col-md-2"><?php echo $form->field($model, 'dob_day')->textInput(array('placeholder' => 'Day'))->label(false); ?> </div> <div class="col-md-2"> <?php $year = date('Y'); // $year = $year-16; $i = 0; while ($i <= 110) { $years[$year - $i] = $year - $i; $i++;
?> </option> <?php } ?> </select> </div> </div> </div> </div> </div> <div class="col-lg-6"> <div class="panel-body" style="line-height:21px;"> <div class="iconic-input right"> <?php $calender = cal_info(0); $month_list = $calender['months']; ?> <label for="Month" class="pull-left">Month</label> <select class="form-control form-control1 selectpicker show-menu-arrow" name="month" id="Month" data-live-search="true"> <option value="" > Month</option> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?php echo $i; ?> " <?php if ($date[1] == $i) { echo 'selected="selected"';
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************/ require "../pear/Hebcal/hebnum.inc"; require "../pear/Hebcal/common.inc"; $calinf = cal_info(CAL_GREGORIAN); $MoY_long = $calinf["months"]; if (isset($_GET["h2g"]) && $_GET["h2g"] && isset($_GET["hm"]) && isset($_GET["hd"]) && isset($_GET["hy"])) { $type = "h2g"; $hd = $_GET["hd"]; $hy = $_GET["hy"]; $hm = $_GET["hm"]; $always29 = array("Iyyar" => true, "Tamuz" => true, "Elul" => true, "Tevet" => true); if (!is_numeric($hd)) { form(true, "Hebrew day must be numeric", ""); } elseif (!is_numeric($hy)) { form(true, "Hebrew year must be numeric", ""); } elseif (!in_array($hm, $hebrew_months)) { form(true, "Unrecognized hebrew month", ""); } elseif ($hy <= 3760) { form(true, "Hebrew year must be in the common era (3761 and above)", "");
public static function monthPop($field, $month = 0, $allow_zero = false, $attributes = array()) { $values = array(); if ($allow_zero) { $values[''] = ''; } $info = cal_info(0); $values += $info['months']; // Set the default class. BasicHTML::setDefaultClass($attributes, 'datePop'); // TODO: Pass the class into this renderer. return BasicHTML::select($field, $values, intval($month), $attributes); }
$datetime = new DateTime(); print_r($datetime); echo PHP_EOL; echo $datetime->format('u'); echo PHP_EOL; //DatePeriod $start = new DateTime('August 1, 2014'); $end = new DateTime('September 1, 2014'); $interval = new DateInterval('P1D'); $range1 = new DatePeriod($start, $interval, $end); foreach ($range1 as $d) { //print "day:".$d->format('d'); //echo PHP_EOL; } //过去六个月 $end = new DateTime(); $start = new DateTime('-6 months '); echo $start->format('m'); echo PHP_EOL; $interval = new DateInterval('P1M'); $range3 = new DatePeriod($start, $interval, $end); //print_r($range3); foreach ($range3 as $m) { print "day:" . $m->format('m'); echo PHP_EOL; } echo PHP_EOL; print_r(cal_info()); $when = new DateTime(); print $when->format('r'); echo PHP_EOL;
function get_rows($elements, $sqlorder = ''){ global $DB, $CFG, $USER; $finalelements = array(); if(!empty($elements)){ list($usql, $params) = $DB->get_in_or_equal($elements); $filter_starttime = optional_param('filter_starttime', 0, PARAM_RAW); if(!empty($filter_starttime)){ $start_year=$filter_starttime['year']; $start_month=$filter_starttime['month']; $start_day=$filter_starttime['day']; $start_hour=$filter_starttime['hour']; $start_minute=$filter_starttime['minute']; $start_second=0; $filter_starttime_con=mktime($start_hour, $start_minute, 0, $start_month, $start_day, $start_year); $months_01 =$filter_starttime_con; }else{ $months_01 =time(); } $months_12=strtotime("-12 months", $months_01); //echo date("F,Y", strtotime("0 months", $months_01)); $sql="SELECT DISTINCT(FROM_UNIXTIME(u.timemodified, '%y%M')) as yearmonth, FROM_UNIXTIME(u.timemodified, '%M') as month, u.id,(SELECT count(lu.id) as count FROM {local_batch_users} lu where lu.userid=u.userid and (lu.courseid IS NOT NULL AND lu.courseid!='0') and FROM_UNIXTIME(lu.timemodified, '%y%M')=FROM_UNIXTIME(u.timemodified, '%y%M') and lu.completion_status=1 ) as course_completions_count, (SELECT count(lu.id) as count FROM {local_batch_users} lu where lu.userid=u.userid and (lu.courseid IS NOT NULL AND lu.courseid!='0') and FROM_UNIXTIME(lu.timemodified, '%y%M')=FROM_UNIXTIME(u.timemodified, '%y%M') ) as course_count FROM {local_batch_users} u where 1=1 and u.userid=$USER->id AND (u.courseid IS NOT NULL AND u.courseid!='0') and u.timemodified >= $months_12 and u.timemodified <= $months_01 group by FROM_UNIXTIME(u.timemodified, '%y%M')"; //order by u.timemodified"; $classrooms = $DB->get_records_sql($sql); $info = cal_info(0); $months=array_flip($info['months']); foreach($classrooms as $classroom){ $months[$classroom->month]=$classroom; } $reportarray = array(); $i=0; foreach($months as $key=>$month){ $manger=new stdClass(); if($i==0) $manger->month_and_year_name = date("F,Y", strtotime("$i months", $months_01)); else $manger->month_and_year_name = date("F,Y", strtotime("-$i months", $months_01)); //$manger->year_name = $month->yearmonth; if(!empty($month->course_completions_count)){ $monthcourse_completions_count=$month->course_completions_count; $monthcourse_count=$month->course_count; }else{ $monthcourse_completions_count=0; $monthcourse_count=0; } $manger->enrolled_courses=$monthcourse_count; $manger->course_completions=$monthcourse_completions_count; $reportarray[] = $manger; $i++; } //print_object($total); return $reportarray; } return $finalelements; }
public static function parseMonthYear($month, $year) { $cal_info = cal_info(CAL_GREGORIAN); if (is_string($month)) { // first check full month names $month_number = DateRange::array_nsearch($month, $cal_info['months']); // if that doesn't work, check abbreviations if ($month_number === false) { $month_number = DateRange::array_nsearch($month, $cal_info['abbrevmonths']); } } else { $month_number = is_int($month) && $month >= 1 && $month <= 12 ? $month : false; } if ($month_number !== false) { $month_days = cal_days_in_month(CAL_GREGORIAN, $month_number, $year); $startDate = mktime(0, 0, 0, $month_number, 1, $year); $endDate = mktime(0, 0, 0, $month_number, $month_days, $year); return new DateRange($startDate, $endDate); } else { return null; } }
<?php print_r(cal_info()); print_r(cal_info(1)); print_r(cal_info(99999));
function months() { $months = cal_info(0); return $months['months']; }