本文整理汇总了PHP中Date::addDays方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::addDays方法的具体用法?PHP Date::addDays怎么用?PHP Date::addDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::addDays方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Date
}
}
}
if (php_sapi_name() != 'cli') {
echo "<pre>\n";
}
$date = new Date("1998-12-24 00:00:00Z");
// First day of week is Sunday
//
// Thursday, 24th December 1998
compare('52', $date->formatLikeSQL('WW'), 'WW (-8)');
compare('52', $date->formatLikeSQL('W1'), 'W1 (-8)');
compare('51', $date->formatLikeSQL('W4'), 'W4 (-8)');
compare('51', $date->formatLikeSQL('W7'), 'W7 (-8)');
compare('52', $date->formatLikeSQL('IW'), 'IW (-8)');
$date->addDays(1);
// Friday, 25th December 1998
compare('52', $date->formatLikeSQL('WW'), 'WW (-7)');
compare('52', $date->formatLikeSQL('W1'), 'W1 (-7)');
compare('51', $date->formatLikeSQL('W4'), 'W4 (-7)');
compare('51', $date->formatLikeSQL('W7'), 'W7 (-7)');
compare('52', $date->formatLikeSQL('IW'), 'IW (-7)');
$date->addDays(1);
// Saturday, 26th December 1998
compare('52', $date->formatLikeSQL('WW'), 'WW (-6)');
compare('52', $date->formatLikeSQL('W1'), 'W1 (-6)');
compare('51', $date->formatLikeSQL('W4'), 'W4 (-6)');
compare('51', $date->formatLikeSQL('W7'), 'W7 (-6)');
compare('52', $date->formatLikeSQL('IW'), 'IW (-6)');
$date->addDays(1);
// Sunday, 27th December 1998
示例2: _checkout_e
//.........这里部分代码省略.........
}
if ($copy->getStatusCd() == OBIB_STATUS_OUT) {
if ($copy->getMbrid() == $mbrid) {
# Renewal
$reachedLimit = $copyQ->hasReachedRenewalLimit($mbrid, $mbr->getClassification(), $copy);
if (!$force && $reachedLimit) {
return new Error($this->_loc->getText("Item %bcode% has reached its renewal limit.", array('bcode' => $bcode)));
} else {
if (!$force && $copy->getDaysLate() > 0) {
return new Error($this->_loc->getText("Item %bcode% is late and cannot be renewed.", array('bcode' => $bcode)));
} else {
$copy->setRenewalCount($copy->getRenewalCount() + 1);
}
}
} else {
if ($force) {
list($dummy, $err) = $this->shelving_cart_e($bcode, $date, $force);
if ($err) {
return $err;
}
$copy = $copyQ->maybeGetByBarcode($bcode);
if (!$copy) {
Fatal::internalError("Copy disappeared mysteriously.");
}
} else {
return new Error($this->_loc->getText("Item %bcode% is already checked out to another member.", array('bcode' => $bcode)));
}
}
} else {
$copy->setRenewalCount(0);
$reachedLimit = $copyQ->hasReachedCheckoutLimit($mbrid, $mbr->getClassification(), $copy->getBibid());
if (!$force && $reachedLimit) {
return new Error($this->_loc->getText("Member has reached checkout limit for this collection."));
}
}
$days = $copyQ->getDaysDueBack($copy);
if ($days <= 0) {
if ($force) {
# the checkout has probably already happened, just guess - FIXME?
$days = 14;
} else {
return new Error($this->_loc->getText("Checkouts are disallowed for this collection."));
}
}
if ($copy->getStatusCd() == OBIB_STATUS_ON_HOLD) {
$holdQ = new BiblioHoldQuery();
$hold = $holdQ->maybeGetFirstHold($copy->getBibid(), $copy->getCopyid());
if ($hold) {
// FIXME: Y2K38. Before 2038, timestamp won't be outside valid range.
$holdAge = Date::daysLater($date, $hold->getHoldBeginDt());
if (OBIB_HOLD_MAX_DAYS > 0 && $holdAge > OBIB_HOLD_MAX_DAYS) {
$tooOld = true;
} else {
$tooOld = false;
}
if ($tooOld || $mbrid == $hold->getMbrid()) {
$holdQ->delete($hold->getBibid(), $hold->getCopyid(), $hold->getHoldid());
} else {
if (!$force) {
return new Error($this->_loc->getText("Item is on hold for another member."));
}
}
}
}
$oldtime = strtotime($copy->getStatusBeginDt());
if ($oldtime > $latest) {
return new Error($this->_loc->getText("Can't change status to an earlier date on item %bcode%.", array('bcode' => $bcode)));
} else {
if ($oldtime == $latest) {
return new Error($this->_loc->getText("Can't change status more than once per second on item %bcode%.", array('bcode' => $bcode)));
} else {
if ($oldtime < $earliest) {
$time = date('Y-m-d H:i:s', $earliest);
} else {
$time = date('Y-m-d H:i:s', $oldtime + 1);
}
}
}
$copy->setStatusCd(OBIB_STATUS_OUT);
$copy->setMbrid($mbrid);
$copy->setStatusBeginDt($time);
if ($due === NULL) {
$copy->setDueBackDt(Date::addDays($date, $days));
} else {
$copy->setDueBackDt($due);
}
if (!$copyQ->updateStatus($copy)) {
Fatal::InternalError("Impossible copyQ update error.");
}
$hist = new BiblioStatusHist();
$hist->setBibid($copy->getBibid());
$hist->setCopyid($copy->getCopyid());
$hist->setStatusCd($copy->getStatusCd());
$hist->setStatusBeginDt($copy->getStatusBeginDt());
$hist->setDueBackDt($copy->getDueBackDt());
$hist->setMbrid($copy->getMbrid());
$hist->setRenewalCount($copy->getRenewalCount());
$histQ = new BiblioStatusHistQuery();
$histQ->insert($hist);
}
示例3: get_weekly_volume_graph
function get_weekly_volume_graph($userID, $connection)
{
$beg_date = new Date();
$end_date = new Date();
$wk = array(0, 0, 0, 0, 0, 0, 0);
$wk_actual = array(0, 0, 0, 0, 0, 0, 0);
$label = array(0, 0, 0, 0, 0, 0, 0);
$filename = array("filename" => "/var/www/vanhlebarsoftware/fitlog/graphs/wklygraph.jpg");
// Get current weeks and prior three weeks volume numbers and the next three weeks.
$day_of_wk = $beg_date->getDayOfWeek();
$beg_date->addDays(-($day_of_wk - 1) + 21);
$end_date->copy($beg_date);
$end_date->addDays(6);
for ($i = 0; $i < 7; $i++) {
// Get the planned volume for this particular week.
$query = "SELECT SUM(seconds) AS seconds FROM flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='p'";
$queryStr = "SELECT SUM(seconds) AS seconds FROM flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='p'";
$result = @mysql_query($query, $connection);
$resultStr = @mysql_query($query, $connection);
if ($result || $resultStr) {
$tmp = 0;
if ($result) {
$row = mysql_fetch_array($result);
$tmp = convert_seconds_minutes($row["seconds"]);
}
if ($resultStr) {
$rowStr = mysql_fetch_array($resultStr);
$tmp += convert_seconds_minutes($rowStr["seconds"]);
}
$wk[$i] = $tmp;
} else {
$wk[$i] = 0;
}
// Get the actual volume for this particular week.
$query = "SELECT SUM(seconds) AS seconds FROM flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='a'";
$queryStr = "SELECT SUM(seconds) AS seconds FROM flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='a'";
$result = @mysql_query($query, $connection);
$resultStr = @mysql_query($queryStr, $connection);
if ($result || $resultStr) {
$tmp = 0;
if ($result) {
$row = mysql_fetch_array($result);
$tmp = convert_seconds_minutes($row["seconds"]);
}
if ($resultStr) {
$rowStr = mysql_fetch_array($resultStr);
$tmp += convert_seconds_minutes($rowStr["seconds"]);
}
$wk_actual[$i] = $tmp;
} else {
$wk_actual[$i] = 0;
}
// Create the labels.
$label[$i] = $end_date->format("%m/%d");
// Move the dates back by one week.
$beg_date->addDays(-7);
$end_date->addDays(-7);
}
for ($i = 0; $i < 7; $i++) {
}
//Setup the graph.
$Graph =& Image_Graph::factory('graph', array(300, 210, TRUE));
$Graph->add(Image_Graph::factory('title', array('Weekly Volume - Actual vs. Planned'), 12));
$Plotarea =& $Graph->addNew('plotarea');
$Dataset =& Image_Graph::factory('dataset');
$Dataset1 =& Image_Graph::factory('dataset');
// Add the actual volume to the graph.
$Dataset1->addPoint($label[6], $wk_actual[6]);
$Dataset1->addPoint($label[5], $wk_actual[5]);
$Dataset1->addPoint($label[4], $wk_actual[4]);
$Dataset1->addPoint($label[3], $wk_actual[3]);
$Dataset1->addPoint($label[2], $wk_actual[2]);
$Dataset1->addPoint($label[1], $wk_actual[1]);
$Dataset1->addPoint($label[0], $wk_actual[0]);
// Add the planned volume to the graph.
$Dataset->addPoint($label[6], $wk[6]);
$Dataset->addPoint($label[5], $wk[5]);
$Dataset->addPoint($label[4], $wk[4]);
$Dataset->addPoint($label[3], $wk[3]);
$Dataset->addPoint($label[2], $wk[2]);
$Dataset->addPoint($label[1], $wk[1]);
$Dataset->addPoint($label[0], $wk[0]);
// Plot the actual data to the graph.
$Plot =& $Plotarea->addNew('line', &$Dataset);
$Plot1 =& $Plotarea->addNew('bar', &$Dataset1);
$Plot1->setFillColor('green@.8');
// Set the axis titles.
$YAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$YAxis->setTitle('Minutes', 'vertical');
$XAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$XAxis->setTitle("Week", array('angle' => 0));
//Output the finished graph to the graphs directory.
$result = $Graph->done($filename);
if ($result) {
var_dump("error creating graph!");
}
}
示例4: get_weekly_volume_graph
function get_weekly_volume_graph()
{
global $wpdb;
global $userdata;
get_currentuserinfo();
$beg_date = new Date();
$end_date = new Date();
$wk = array(0, 0, 0, 0);
$label = array(0, 0, 0, 0);
$filename = array("filename" => "/var/www/vanhlebarsoftware/wp-content/plugins/fitnesslog/graphs/wklygraph.png");
// Get current weeks and prior three weeks volume numbers.
$day_of_wk = $beg_date->getDayOfWeek();
$beg_date->addDays(-($day_of_wk - 1));
$end_date->copy($beg_date);
$end_date->addDays(6);
for ($i = 0; $i < 4; $i++) {
$query = "SELECT user_id, SUM(seconds) AS seconds FROM " . $wpdb->prefix . "flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userdata->ID . " GROUP BY user_id";
$result = $wpdb->get_results($query, ARRAY_A);
if ($result) {
foreach ($result as $row) {
$wk[$i] = convert_seconds_minutes($row["seconds"]);
}
} else {
$wk[$i] = 0;
}
// Add any strength training that we have done to the total.
$query = "SELECT user_id, SUM(seconds) AS seconds FROM " . $wpdb->prefix . "flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userdata->ID . " GROUP BY user_id";
$result = $wpdb->get_results($query, ARRAY_A);
if ($result) {
foreach ($result as $row) {
$wk[$i] = $wk[$i] + convert_seconds_minutes($row["seconds"]);
}
}
// Create the labels.
$label[$i] = $end_date->format("%m/%d");
// Move the dates back by one week.
$beg_date->addDays(-7);
$end_date->addDays(-7);
}
//Setup the graph.
$Graph =& Image_Graph::factory('graph', array(175, 175), true);
$Plotarea =& $Graph->addNew('plotarea');
$Dataset =& Image_Graph::factory('dataset');
$Dataset->addPoint($label[3], $wk[3]);
$Dataset->addPoint($label[2], $wk[2]);
$Dataset->addPoint($label[1], $wk[1]);
$Dataset->addPoint($label[0], $wk[0]);
$Plot =& $Plotarea->addNew('bar', &$Dataset);
$Plot->setFillColor('green');
$YAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$YAxis->setTitle('Minutes', 'vertical');
$XAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
// $XAxis->setFontAngle( "vertical" );
$XAxis->setTitle("Week", array('angle' => 0));
//Output the finished graph to the graphs directory.
$result = $Graph->done($filename);
if ($result) {
var_dump("error creating graph!");
}
}
示例5: Date
<?php
$date = new Date();
$date->setDMY(28, 4, 2010);
$date->addDays(5);
$dcs = $date->getArray();
print_r($dcs);
示例6: getDays
function getDays($since, $until)
{
$s = strtotime($since);
$u = strtotime($until);
assert('$s <= $u');
$since = date('Y-m-d', $s);
$until = date('Y-m-d', $u);
$days = array();
for (; $since != $until; $since = Date::addDays($since, 1)) {
array_push($days, $since);
}
array_push($days, $until);
return $days;
}
示例7: displayErrorPage
$copyQ->close();
displayErrorPage($copyQ);
}
if (isset($_POST['date_from']) && isset($_POST['dueDate']) && $_POST['date_from'] == 'override') {
list($dueDate, $err) = Date::read_e($_POST['dueDate']);
if ($err) {
$pageErrors["dueDate"] = $loc->getText("Bad date: %err%", array('err' => $err->toStr()));
$_SESSION["postVars"] = $_POST;
$_SESSION["pageErrors"] = $pageErrors;
header("Location: ../circ/mbr_view.php?mbrid=" . U($mbrid));
exit;
}
$_SESSION['due_date_override'] = $_POST['dueDate'];
} else {
list($today, $err) = Date::read_e("today");
$dueDate = Date::addDays($today, $daysDueBack);
}
if ($copy->getStatusCd() == OBIB_STATUS_OUT) {
//Item already checked out, let's see if it's a renewal
if ($renewal) {
//Check to see if the renewal limit has been reached
$reachedLimit = $copyQ->hasReachedRenewalLimit($mbrid, $mbrClassification, $copy);
if ($copyQ->errorOccurred()) {
$copyQ->close();
displayErrorPage($copyQ);
}
if ($reachedLimit) {
$foundError = TRUE;
$pageErrors["barcodeNmbr"] = $loc->getText("checkoutErr7", array("barcode" => $barcode));
} else {
if ($copy->getDaysLate() > 0) {
示例8: createCalendarioMes
public static function createCalendarioMes($mes, $ano, $modo)
{
//include_once('CalendarShow.class.php');
$cal = new CalendarShow();
$fecha = new Date();
$fecha->setDay(1);
$fecha->setMonth($mes);
$fecha->setYear($ano);
$fecha_uno = $fecha->toString(FMT_DATEMYSQL);
$fecha->addMonths(1);
$fecha->addDays(-1);
$fecha_dos = $fecha->toString(FMT_DATEMYSQL);
$diasEvento = array();
$diasTareas = array();
$c1 = TareaPeer::getCriterioAlcance();
$crit0 = $c1->getNewCriterion(TareaPeer::FECHA_INICIO, $fecha_uno . " 00:00:00", Criteria::GREATER_EQUAL);
$crit1 = $c1->getNewCriterion(TareaPeer::FECHA_INICIO, $fecha_dos . " 23:59:59", Criteria::LESS_EQUAL);
$crit0->addAnd($crit1);
$crit2 = $c1->getNewCriterion(TareaPeer::FECHA_VENCIMIENTO, $fecha_uno . " 00:00:00", Criteria::GREATER_EQUAL);
$crit3 = $c1->getNewCriterion(TareaPeer::FECHA_VENCIMIENTO, $fecha_dos . " 23:59:59", Criteria::LESS_EQUAL);
$crit2->addAnd($crit3);
$crit0->addOr($crit2);
$c1->add($crit0);
$c1->setDistinct();
$dias = TareaPeer::doSelect($c1);
$ruta = UsuarioPeer::getRuta();
foreach ($dias as $dia) {
$fecha_inicio = $dia->getFechaInicio('Y-m-d');
$fecha_fin = $dia->getFechaVencimiento('Y-m-d');
if ($fecha_inicio == $fecha_fin) {
if ($dia->getEsEvento() == '1') {
if (!isset($diasEvento[$fecha_inicio])) {
$diasEvento[$fecha_inicio] = "";
}
//$diasEvento[$fecha_inicio] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
$diasEvento[$fecha_inicio] .= $dia->getResumen();
} else {
if (!isset($diasTareas[$fecha_inicio])) {
$diasTareas[$fecha_inicio] = "";
}
//$diasTareas[$fecha_inicio] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
$diasTareas[$fecha_inicio] .= $dia->getResumen();
}
} else {
if ($dia->getEsEvento() == '1') {
if (!isset($diasEvento[$fecha_inicio])) {
$diasEvento[$fecha_inicio] = "";
}
if (!isset($diasEvento[$fecha_fin])) {
$diasEvento[$fecha_fin] = "";
}
//$diasEvento[$fecha_inicio] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Inicio Evento: ".$dia->getResumen()."</a></div>";
$diasEvento[$fecha_inicio] .= $dia->getResumen();
//$diasEvento[$fecha_fin] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Vencimiento Evento: ".$dia->getResumen()."</a></div>";
$diasEvento[$fecha_fin] .= $dia->getResumen();
} else {
if (!isset($diasTareas[$fecha_inicio])) {
$diasTareas[$fecha_inicio] = "";
}
if (!isset($diasTareas[$fecha_fin])) {
$diasTareas[$fecha_fin] = "";
}
//$diasTareas[$fecha_inicio] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Inicio Tarea: ".$dia->getResumen()."</a></div>";
$diasTareas[$fecha_inicio] .= $dia->getResumen();
//$diasTareas[$fecha_fin] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Vencimiento Tarea: ".$dia->getResumen()."</a></div>";
$diasTareas[$fecha_fin] .= $dia->getResumen();
}
}
/*
if ($dia->getEsEvento() == '1') {
if (isset($diasEvento[$fecha]))
$diasEvento[$fecha] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
else
$diasEvento[$fecha] = "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
}
else {
if (isset($diasTareas[$fecha]))
$diasTareas[$fecha] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
else
$diasTareas[$fecha] = "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>";
}
*/
$filters = array();
$filters['fecha_inicio']['from'] = $dia->getFechaInicio('d/m/Y');
$filters['fecha_inicio']['to'] = $dia->getFechaVencimiento('d/m/Y');
if ($modo) {
if ($fecha_inicio != $fecha_fin) {
$cal->setDateLink($fecha_inicio, "tareas/list?mes=" . $dia->getFechaInicio('m') . "&year=" . $dia->getFechaInicio('Y') . "&filters=" . $filters);
$cal->setDateLink($fecha_fin, "tareas/list?mes=" . $dia->getFechaInicio('m') . "&year=" . $dia->getFechaInicio('Y') . "&filters=" . $filters);
} else {
$cal->setDateLink($fecha_inicio, "tareas/list?mes=" . $dia->getFechaInicio('m') . "&year=" . $dia->getFechaInicio('Y') . "&filters=" . $filters);
}
} else {
if ($fecha_inicio != $fecha_fin) {
$cal->setDateLink($fecha_inicio, "1");
$cal->setDateLink($fecha_fin, "1");
} else {
$cal->setDateLink($fecha_inicio, "1");
}
}
//.........这里部分代码省略.........
示例9: array
$value .= input_tag($control_name, $valor ? $valor->getTextoCorto() : $campo->getDefecto(), array('control_name' => $control_name, 'size' => $tamano));
} elseif ($campo->esTipoFecha()) {
if ($valor == null) {
$valor_fecha = "";
switch ($campo->getDefecto()) {
case 1:
$fecha = new Date();
$valor_fecha = $fecha->getTimestamp();
case 2:
$fecha = new Date();
$fecha->addDays(-1);
$valor_fecha = $fecha->getTimestamp();
break;
case 3:
$fecha = new Date();
$fecha->addDays(1);
$valor_fecha = $fecha->getTimestamp();
break;
case 4:
$fecha = new Date();
$fecha->setFirstDayOfMonth();
$valor_fecha = $fecha->getTimestamp();
break;
case 5:
$fecha = new Date();
$fecha->setLastDayOfMonth();
$valor_fecha = $fecha->getTimestamp();
break;
case 6:
$fecha = new Date();
$fecha->setFirstDayOfYear();
示例10: getTemplateArrayCalendar
function getTemplateArrayCalendar($o_minDay, $s_date, $period)
{
// today
$today = new Date(getDateFromTimestamp(time()));
$tsToday = $today->getTimestamp();
// date asked for statistics
$dateAsked = new Date($s_date);
// used for going througt the month
$date = new Date($s_date);
$month = $date->getMonth();
$year = $date->getYear();
$prefixDay = $year . "-" . $month . "-";
$date->setDate($prefixDay . '01');
$week = $date->getWeek();
$day = 1;
$ts = $date->getTimestamp();
while ($date->getMonth() == $month) {
// day exists in stats, isn't it too old or in the future ?
if ($date->getTimestamp() >= $o_minDay->getTimestamp() && $date->getTimestamp() <= $tsToday) {
$exists = 1;
} else {
$exists = 0;
}
// day selected for stats view ?
if ($period == DB_ARCHIVES_PERIOD_DAY && $date->getDay() == $dateAsked->getDay() || $period == DB_ARCHIVES_PERIOD_WEEK && $date->getWeek() == $dateAsked->getWeek() || $period == DB_ARCHIVES_PERIOD_MONTH || $period == DB_ARCHIVES_PERIOD_YEAR) {
$selected = 1;
} else {
$selected = 0;
}
$weekNo = $date->getWeek() - $week;
if (defined('MONDAY_FIRST') && MONDAY_FIRST == 'no' && date("w", $ts) == 0) {
$weekNo += 1;
}
$dayOfWeek = (int) (!defined('MONDAY_FIRST') || MONDAY_FIRST == 'yes' ? date("w", $ts) == 0 ? 6 : date("w", $ts) - 1 : date("w", $ts));
$return[$weekNo][$dayOfWeek] = array('day' => substr($date->getDay(), 0, 1) === '0' ? substr($date->getDay(), 1, 2) : $date->getDay(), 'date' => $date->get(), 'exists' => $exists, 'selected' => $selected);
$date->addDays(1);
//these 2 lines useless? to check
$ts = $date->getTimeStamp();
$date->setTimestamp($ts);
}
foreach ($return as $key => $r) {
$row =& $return[$key];
for ($i = 0; $i < 7; $i++) {
if (!isset($row[$i])) {
$row[$i] = "-";
}
}
ksort($row);
}
return $return;
}
示例11: updateItemsFormularioFromRequest
protected function updateItemsFormularioFromRequest($empresa, $id_tabla = null)
{
//parametros obtenidos de la formulario_modelo.
if (!$empresa) {
return null;
}
$campos = $empresa->getCamposFormularioOrdenadosAlcancetablas($id_tabla);
foreach ($campos as $campo) {
$name_campo = "campo_" . $campo->getIdCampo();
$datos_campo = $this->getRequestParameter($name_campo);
if (!$campo->esTipoLista()) {
$item_base = $campo->getElementoUnico();
$name_item = "item_base_" . $item_base->getIdItemBase() . "";
$item = $this->getItemOrCreate($item_base->getIdItemBase());
$item->setIdFormulario($this->formulario->getIdFormulario());
if ($campo->esTipoTextoCorto()) {
$item->setTextoCorto(isset($datos_campo[$name_item]) && $datos_campo[$name_item] != '' ? $datos_campo[$name_item] : null);
} elseif ($campo->esTipoTextoLargo()) {
$item->setTextoLargo(isset($datos_campo[$name_item]) && $datos_campo[$name_item] != '' ? $datos_campo[$name_item] : null);
} elseif ($campo->esTipoNumero()) {
$item->setNumero(isset($datos_campo[$name_item]) && $datos_campo[$name_item] != '' ? $datos_campo[$name_item] : null);
} elseif ($campo->esTipoFecha()) {
if (isset($datos_campo[$name_item]) && $datos_campo[$name_item] != "") {
$value = sfContext::getInstance()->getI18N()->getTimestampForCulture($datos_campo[$name_item], $this->getUser()->getCulture());
$mi_date = new Date($value);
$item->setFecha($mi_date->getTimestamp());
//BORRAMOS LAS TAREAS QUE EXISTAN PARA ESTE ITEM, AUNQUE SEA UN CAMPO SIN ALARMA, POR SI ACASO
if ($item->getIdItem() != 0) {
$c = new Criteria();
$c->addAnd(TareaPeer::ID_CAMPO, $campo->getIdCampo(), Criteria::EQUAL);
$c->addAnd(TareaPeer::ID_FORMULARIO, $this->formulario->getIdFormulario(), Criteria::EQUAL);
TareaPeer::doDelete($c);
}
//CAMPOS CON ALARMA
if ($campo->getMostrarEnPadre() && isset($datos_campo["tiene_alarma"])) {
$item->setSiNo(true);
$item->setNumero($datos_campo['usuario_avisar']);
if (!isset($datos_campo['cuando_alarma'])) {
$datos_campo['cuando_alarma'] = array();
}
if (!is_array($datos_campo['cuando_alarma'])) {
$datos_campo['cuando_alarma'] = array($datos_campo['cuando_alarma']);
}
$cuando = implode("##", $datos_campo['cuando_alarma']);
$item->setTextoCorto($cuando);
//CREAMOS TAREAS
foreach ($datos_campo['cuando_alarma'] as $cu) {
if ($cu == "1") {
$fecha_avisar = new Date($mi_date->getTimestamp());
$fecha_avisar->addMonths(-1);
$txt_avisar = "Falta un mes para";
} else {
if ($cu == "2") {
$fecha_avisar = new Date($mi_date->getTimestamp());
$fecha_avisar->addWeeks(-2);
$txt_avisar = "Faltan dos semanas para";
} else {
if ($cu == "3") {
$fecha_avisar = new Date($mi_date->getTimestamp());
$fecha_avisar->addWeeks(-1);
$txt_avisar = "Falta una semana para";
} else {
if ($cu == "4") {
$fecha_avisar = new Date($mi_date->getTimestamp());
$fecha_avisar->addDays(-1);
$txt_avisar = "Falta un día para";
} else {
if ($cu == "5") {
$fecha_avisar = new Date($mi_date->getTimestamp());
//$fecha_avisar->addMonths(-1);
$txt_avisar = "";
}
}
}
}
}
$hoy = new Date();
if ($fecha_avisar->getTimestamp() < $hoy->getTimestamp()) {
continue;
}
$tarea = new Tarea();
$tarea->setIdCampo($campo->getIdCampo());
$tarea->setIdFormulario($this->formulario->getIdFormulario());
$tarea->setIdEmpresa(sfContext::getInstance()->getUser()->getAttribute('idempresa'));
if ($item->getNumero() != "" || $item->getNumero() != "0") {
$tarea->setAvisarEmail(true);
$tarea->setIdUsuario($item->getNumero());
} else {
$tarea->setAvisarEmail(false);
}
$mtabla = TablaPeer::retrieveByPK($id_tabla);
if (!$mtabla instanceof Tabla) {
$mtabla = new Tabla();
}
$txt = $txt_avisar . " el " . $item->__toString() . ", '" . strtolower($campo->getNombre()) . "' de '" . strtolower($mtabla->getNombre()) . "' para '" . $this->formulario->__toString() . "'";
$tarea->setResumen($txt);
$tarea->setEsEvento(false);
$tarea->setIdEstadoTarea(TareaPeer::ID_ESTADO_TAREA_PLANEADO);
$fecha_avisar->setHours(8);
$fecha_avisar->setMinutes(0);
//.........这里部分代码省略.........
示例12:
echo_code($date->format('%e/%m/%y %h.%M.%S'));
echo_code($date->format2('NPDD/NPMM/YY NPHH.MI.SS'));
?>
<h4>Conversion to another time zone:</h4>
<?php
$date->convertTZbyID("Asia/Calcutta");
echo_code($date->format2('"Time zone ID:" TZR'));
echo_code($date->format2('"Time zone name:" TZN'));
echo_code($date->format2('"Time zone code:" TZC'));
echo_code($date->format2('"Time zone offset:" TZO'));
echo "<br />\n";
echo_code($date->format2('DD/MM/YYYY HH.MI.SSTZO (TZC)'));
?>
<h4>Addition/Subtraction:</h4>
<?php
$date->addDays(-1);
echo_code($date->format2('DD/MM/YYYY HH.MI.SS'));
$date->addHours(13);
echo_code($date->format2('DD/MM/YYYY HH.MI.SS'));
?>
<h4>12-hour time:</h4>
<?php
echo_code($date->format('%d/%m/%Y %I.%M.%S %p'));
echo_code($date->format2('DD/MM/YYYY HH12.MI.SS am'));
?>
<h4>Display micro-time:</h4>
<?php
$date->setSecond(3.201282);
echo_code($date->format('%d/%m/%Y %I.%M.%s'));
echo_code($date->format2('DD/MM/YYYY HH12.MI.SS.FFFFFF'));
?>
示例13: create_history
function create_history($connection, $template)
{
$userid = getUserID($connection);
$yearmoday = explode("-", $_SESSION["nav_month"]);
// See if the users is trying to display a month other than the current month.
if ($yearmoday != NULL) {
$display_mo = new Date();
$display_mo->setDayMonthYear($yearmoday[2], $yearmoday[1], $yearmoday[0]);
} else {
$display_mo = new Date();
}
$LastDay = $display_mo->getYear() . "-" . $display_mo->getMonth() . "-" . $display_mo->GetDaysInMonth();
$FirstDay = $display_mo->format("%Y") . "-" . $display_mo->format("%m") . "-" . "1";
$sbr_type = array("s", "b", "r");
$total_duration = array(0, 0, 0);
$total_distance = array(0, 0, 0);
$total_calories = array(0, 0, 0);
$i = 0;
while ($i < 3) {
$query = "SELECT * FROM flmain WHERE user_id={$userid} AND workout_date>='" . $FirstDay . "' AND workout_date<='" . $LastDay . "' AND sbr_type='" . $sbr_type[$i] . "' ORDER BY workout_date ASC";
$result = @mysql_query($query, $connection);
if (mysql_num_rows($result) > 0) {
//set the correct template block
selectActivityBlock($i, $template);
//Get the first row of data and compare it to the day of the month to see if we have any
//data to display on the current day.
$row = mysql_fetch_array($result);
//Out put each day of the displayed month. If we have data for that day
//then put it into the grid also.
$currentDay = new Date();
$nextMonth = new Date();
$currentDay->setDayMonthYear(1, $display_mo->getMonth(), $display_mo->getYear());
//Move the display_mo to the first day of the next month.
$nextMonth->setDayMonthYear($display_mo->GetDaysInMonth(), $display_mo->getMonth(), $display_mo->getYear());
$nextMonth->addDays(1);
while ($currentDay->before($nextMonth)) {
// select the correct activity block.
selectActivityBlock($i, $template);
$template->setVariable("UPDATE", $currentDay->format("%Y-%m-%d"));
$template->setVariable("DATE", $currentDay->format("%b %e, %Y"));
//Check to see if the current day matches the current row, if so then output it.
if (!strcmp($currentDay->format("%Y-%m-%d"), $row["workout_date"])) {
outputCurrentDay($template, $row, $i);
//Add up the duration, distance and calories
$total_dur[$i] = $total_dur[$i] + convert_time_seconds($row["duration"]);
$total_dist[$i] = $total_dist[$i] + $row["distance"];
$total_cal[$i] = $total_cal[$i] + $row["cals_burned"];
$row = mysql_fetch_array($result);
}
$template->parseCurrentBlock();
$currentDay->addDays(1);
}
outputTotals($template, $total_dur[$i], $total_dist[$i], $total_cal[$i], $i);
} else {
$currentDay = new Date();
$nextMonth = new Date();
$currentDay->setDayMonthYear(1, $display_mo->getMonth(), $display_mo->getYear());
//Move the display_mo to the first day of the next month.
$nextMonth->setDayMonthYear($display_mo->GetDaysInMonth(), $display_mo->getMonth(), $display_mo->getYear());
$nextMonth->addDays(1);
while ($currentDay->before($nextMonth)) {
// set the correct activity block.
selectActivityBlock($i, $template);
$template->setVariable("UPDATE", $currentDay->format("%Y-%m-%d"));
$template->setVariable("DATE", $currentDay->format("%b %e, %Y"));
$template->parseCurrentBlock();
$currentDay->addDays(1);
}
}
$i = $i + 1;
}
}