本文整理汇总了PHP中date_add函数的典型用法代码示例。如果您正苦于以下问题:PHP date_add函数的具体用法?PHP date_add怎么用?PHP date_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了date_add函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$colonie = $builder->getData();
$lastDate = $colonie->getDateColonie();
if (!$colonie->getVisites()->isEmpty()) {
$date = $colonie->getVisites()->last()->getDate();
if ($lastDate < $date) {
$lastDate = $date;
}
}
if (!$colonie->getTranshumances()->isEmpty()) {
$date = $colonie->getTranshumances()->last()->getDate();
if ($lastDate < $date) {
$lastDate = $date;
}
}
if (!$colonie->getRecoltes()->isEmpty()) {
$date = $colonie->getRecoltes()->last()->getDate();
if ($lastDate < $date) {
$lastDate = $date;
}
}
if (!$colonie->getRemerages()->isEmpty()) {
$date = $colonie->getRemerages()->last()->getDate();
if ($lastDate < $date) {
$lastDate = $date;
}
}
$startDate = date_add($lastDate, date_interval_create_from_date_string("1 days"));
$startDateFormat = date_format($startDate, "Y-m-d");
$builder->add('dateMort', 'collot_datetime', array('pickerOptions' => array('format' => 'dd/mm/yyyy', 'autoclose' => true, 'startDate' => (string) $startDateFormat, 'endDate' => date("Y-m-d"), 'startView' => 'month', 'minView' => 'month', 'maxView' => 'month', 'todayBtn' => false, 'todayHighlight' => true, 'keyboardNavigation' => true, 'language' => 'fr', 'forceParse' => true, 'pickerReferer ' => 'default', 'pickerPosition' => 'bottom-right', 'viewSelect' => 'month', 'initialDate' => date("Y-m-d")), 'constraints' => new CheckDateMort($colonie), 'read_only' => true, 'attr' => array('input_group' => array('prepend' => '.icon-calendar'))))->add('causes', 'entity', array('class' => 'KGBeekeepingManagementBundle:Cause', 'choice_label' => 'libelle', 'multiple' => true, 'required' => false))->add('autreCause', 'text', array('required' => false, 'constraints' => new CheckCauseMort()));
}
示例2: indexChef
public function indexChef()
{
$filiere = Session::get('user')->filieres[0];
$etudiants_count = Filiere::nbreEtudiantByFiliere($filiere->id);
$enseignants_count = Enseignant::count();
$etudiants = Etudiant::etudiants_plus_3_absences();
$promotions = $filiere->promos;
$promos_count = count($promotions);
$stats_cours = array();
$today = Carbon::now();
$liste = null;
$j = 0;
$absences_count = 0;
if ($promos_count > 0) {
foreach ($promotions as $promotion) {
$absences_count = $absences_count + Filiere::nbreAbsencesByPromo($promotion->id);
}
}
$stats_cours = array();
$today = Carbon::now();
for ($i = 0; $i < 10; $i++) {
$nb = Absence::whereDate('created_at', '=', date("Y-m-d", strtotime($today)))->count();
date_add($today, date_interval_create_from_date_string('-1 days'));
array_push($stats_cours, $nb);
}
return View('app/dashboardChef', ['etudiants_count' => $etudiants_count, 'enseignants_count' => $enseignants_count, 'absences_count' => $absences_count, 'promos_count' => $promos_count, 'etudiants' => $etudiants, 'statistics' => $liste[0], 'promotions' => $promotions, 'filiere' => $filiere, 'statistics' => $stats_cours]);
}
示例3: depreciated_date
public function depreciated_date()
{
$date = date_create($this->purchase_date);
date_add($date, date_interval_create_from_date_string($this->get_depreciation()->months . ' months'));
return $date;
//date_format($date, 'Y-m-d'); //don't bake-in format, for internationalization
}
示例4: getDates
function getDates($dayofmonth, $months = 0)
{
$dayofmonth = zeropad($dayofmonth);
$year = date('Y');
$month = date('m');
if (date('d') >= $dayofmonth) {
$date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
$date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
date_add($date_end, date_interval_create_from_date_string('1 月'));
} else {
// Billing day will happen this month, therefore started last month
$date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
$date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
date_sub($date_start, date_interval_create_from_date_string('1 月'));
}
if ($months > 0) {
date_sub($date_start, date_interval_create_from_date_string($months . ' 月'));
date_sub($date_end, date_interval_create_from_date_string($months . ' 月'));
}
# date_sub($date_start, date_interval_create_from_date_string('1 月'));
date_sub($date_end, date_interval_create_from_date_string('1 天'));
$date_from = date_format($date_start, 'Ymd') . "000000";
$date_to = date_format($date_end, 'Ymd') . "235959";
date_sub($date_start, date_interval_create_from_date_string('1 月'));
date_sub($date_end, date_interval_create_from_date_string('1 月'));
$last_from = date_format($date_start, 'Ymd') . "000000";
$last_to = date_format($date_end, 'Ymd') . "235959";
$return['0'] = $date_from;
$return['1'] = $date_to;
$return['2'] = $last_from;
$return['3'] = $last_to;
return $return;
}
示例5: get_comic
function get_comic($comic, $date) {
global $sql;
$res=$sql->query("select gfx, strftime('%s', 'now')-strftime('%s', timestamp) as last from comics_date where comic='$comic' and date='$date'");
if($elem=$sql->fetch_assoc($res)) {
if($elem['gfx'])
return $elem["gfx"];
elseif(!date_is_after($date, date_add(date_get_today(), -60))) {
return null;
}
elseif((!date_is_after($date, date_add(date_get_today(), -2)))&&($elem['last']>24*60*60))
return null;
elseif($elem['last']>60)
return null;
}
$fun="{$comic}_check";
$gfx=$fun($date);
if($gfx)
$gfx_sql="\"$gfx\"";
else
$gfx_sql="null";
$sql->query("insert or replace into comics_date values ('$comic', '$date', $gfx_sql, null, datetime('now'))");
return $gfx;
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validation = Validator::make(Input::all(), ['duration' => 'required | integer', 'pace' => 'required | integer', 'dog_friendliness' => 'required | integer', 'comments' => 'required']);
if ($validation->fails()) {
return Redirect::back()->withInput()->withErrors($validation->messages());
}
$walk = new Walk();
$duration = Input::get('duration');
$dog_friendliness = Input::get('dog_friendliness');
$pace = Input::get('pace');
$comments = Input::get('comments');
$start = new DateTime();
$start->setTimezone(new DateTimeZone('America/New_York'));
$dateInterval = new DateInterval('PT' . $duration . 'M');
$finish = date_add($start, $dateInterval);
$walk->start = $start;
$walk->finish = $finish;
$walk->host_id = Auth::user()->id;
$walk->dog_friendliness = $dog_friendliness;
$walk->pace = $pace;
$walk->comments = $comments;
if ($walk->save()) {
return Redirect::route('walk.index');
}
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var EntityManager em */
$em = $this->getContainer()->get('doctrine')->getManager();
$users = $em->getRepository('ESNUserBundle:User')->findBy(array("esner" => 1));
$concerned_users = new ArrayCollection();
/** @var User $user */
foreach ($users as $user) {
/** @var EsnerFollow $follow */
$follow = $user->getFollow();
if ($follow) {
$trial = $follow->getTrialstarted();
$end_trial = $trial;
date_add($trial, date_interval_create_from_date_string('21 days'));
$now = new \DateTime();
if ($end_trial->format('d/m/Y') == $now->format('d/m/Y')) {
$concerned_users->add($user);
}
}
}
/** @var User $concerned_user */
foreach ($concerned_users as $concerned_user) {
$message = \Swift_Message::newInstance()->setSubject('[ESN Lille][ERP] Periode d\'essaie terminé pour ' . $concerned_user->getFullname())->setFrom($this->getContainer()->getParameter('mailer_from'))->setTo($user->getEmail())->setBody($this->getContainer()->get('templating')->render('ESNHRBundle:Emails:trial_ended.html.twig', array('user' => $concerned_user)), 'text/html');
$this->getContainer()->get('mailer')->send($message);
}
}
示例8: getSMA_sub_real
function getSMA_sub_real($company, $from = "1900-01-01 00:00:00", $to = null, $dataorg = "json", $samplePeriod = 15, $enSignals = false, $host, $db, $user, $pass)
{
$intervalPeriod = $samplePeriod * 1.5;
//from date has to be adjusted for the bollinger bands
$date = date_create($from);
date_add($date, date_interval_create_from_date_string("-{$intervalPeriod} days"));
$fromAdjusted = date_format($date, "Y-m-d");
$dataOhlc = [];
//OHLC data format [timestamp,open,high,low,close,volume]
if ($dataorg == "highchart") {
$dataOhlc = getOHLC($company, $fromAdjusted, $to, "array2", $host, $db, $user, $pass);
} else {
$dataOhlc = getOHLC($company, $fromAdjusted, $to, "array", $host, $db, $user, $pass);
}
//Return if $dataOhlc is null
if ($dataOhlc == [] || $dataOhlc == 0) {
return 0;
}
//Input for SMA functions should be [timestamp,close]
$ctr = 0;
foreach ((array) $dataOhlc as $ohlc) {
$dbreturn[$ctr][0] = $ohlc[0];
//timestamp
$dbreturn[$ctr++][1] = $ohlc[4];
//close
}
return $dbreturn;
}
示例9: groupHasThirdWeekHours
function groupHasThirdWeekHours($groupInfo)
{
$today = new DateTime();
date_add($today, date_interval_create_from_date_string('14 days'));
$nextWeek = date_format($today, "Y-m-d");
return strcmp($groupInfo['addHrsType'], "week") == 0 && strcmp($nextWeek, $groupInfo['startDate']) > 0 && strcmp($nextWeek, $groupInfo['endDate']) < 0;
}
示例10: checkValidCode
public function checkValidCode($referCode)
{
$isEnabled = Engine_Api::_()->getApi('settings', 'core')->getSetting('user_referral_enable', 1);
$period = Engine_Api::_()->getApi('settings', 'core')->getSetting('user_referral_trial', 0);
$now = date("Y-m-d H:i:s");
$invite = Engine_Api::_()->invite()->getRowCode($referCode);
//check invite code active
if (isset($invite) && !$invite->active) {
return false;
}
if ($isEnabled && $invite) {
//if exist code then get expire date
if ($period == 1) {
$type = 'day';
} else {
$type = 'days';
}
$expiration_date = date_add(date_create($invite->timestamp), date_interval_create_from_date_string($period . " " . $type));
$nowDate = date_create($now);
if ($period != 0) {
if ($nowDate >= $expirationDate) {
return true;
} else {
return false;
}
} else {
//if code never expired
return true;
}
} else {
return false;
}
}
示例11: addDaysFromNow
private function addDaysFromNow($days)
{
$now = date('Y-m-d');
$date = date_create($now);
date_add($date, date_interval_create_from_date_string($days . ' days'));
return date_format($date, 'Y-m-d');
}
示例12: indexAction
public function indexAction(Request $request, SessionInterface $session)
{
Util::checkUserIsLoggedInAndRedirect();
$clientSettings = $session->get('client/settings');
$slaId = $request->get('id');
$dateFrom = $request->get('date_from');
$dateTo = $request->get('date_to');
$issues = $this->getRepository(Sla::class)->getIssues($slaId, $dateFrom, $dateTo);
$dates = array();
$succeeded = array();
$breached = array();
$dateTemporary = new \DateTime($dateFrom, new \DateTimeZone($clientSettings['timezone']));
while (date_format($dateTemporary, 'Y-m-d') <= $dateTo) {
$dates[] = date_format($dateTemporary, 'Y-m-d');
$succeeded[end($dates)] = 0;
$breached[end($dates)] = 0;
date_add($dateTemporary, date_interval_create_from_date_string('1 days'));
}
while ($issues && ($issue = $issues->fetch_array(MYSQLI_ASSOC))) {
if ($issue['sla_value'] >= 0) {
$succeeded[substr($issue['stopped_date'], 0, 10)]++;
} else {
$breached[substr($issue['stopped_date'], 0, 10)]++;
}
}
$data = array('dates' => $dates, 'succeeded' => $succeeded, 'breached' => $breached);
return new JsonResponse($data);
}
示例13: historico_acceso
public function historico_acceso($data, $limit = -1, $offset = -1)
{
$fecha = date_create(date('Y-m-j'));
date_add($fecha, date_interval_create_from_date_string('-1 month'));
$data['fecha_inicial'] = date_format($fecha, 'm');
$data['fecha_final'] = $data['fecha_final'] = date('m');
$this->db->select("AES_DECRYPT(h.email,'{$this->key_hash}') AS email", FALSE);
$this->db->select('p.id_perfil, p.perfil, p.operacion');
$this->db->select('u.nombre,u.apellidos');
$this->db->select('h.ip_address, h.user_agent, h.id_usuario');
$this->db->select("( CASE WHEN h.fecha = 0 THEN '' ELSE DATE_FORMAT(FROM_UNIXTIME(h.fecha),'%d-%m-%Y %H:%i:%s') END ) AS fecha", FALSE);
$this->db->from($this->historico_acceso . ' As h');
$this->db->join($this->usuarios . ' As u', 'u.id = h.id_usuario', 'LEFT');
$this->db->join($this->perfiles . ' As p', 'u.id_perfil = p.id_perfil', 'LEFT');
//gmt_to_local( $timestamp, 'UM1', TRUE) )
if ($data['fecha_inicial'] and $data['fecha_final']) {
$this->db->where("( CASE WHEN h.fecha = 0 THEN '' ELSE DATE_FORMAT(FROM_UNIXTIME(h.fecha),'%m') END ) = ", $data['fecha_inicial']);
$this->db->or_where("( CASE WHEN h.fecha = 0 THEN '' ELSE DATE_FORMAT(FROM_UNIXTIME(h.fecha),'%m') END ) = ", $data['fecha_final']);
}
if ($limit != -1) {
$this->db->limit($limit, $offset);
}
$this->db->order_by('h.fecha', 'desc');
$login = $this->db->get();
if ($login->num_rows() > 0) {
return $login->result();
} else {
return FALSE;
}
$login->free_result();
}
示例14: getDates
function getDates($dayofmonth, $months = 0)
{
$dayofmonth = zeropad($dayofmonth);
$year = date('Y');
$month = date('m');
if (date('d') > $dayofmonth) {
// Billing day is past, so it is next month
$date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
$date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
date_add($date_end, date_interval_create_from_date_string('1 month'));
} else {
// Billing day will happen this month, therefore started last month
$date_end = date_create($year . '-' . $month . '-' . $dayofmonth);
$date_start = date_create($year . '-' . $month . '-' . $dayofmonth);
date_sub($date_start, date_interval_create_from_date_string('1 month'));
}
if ($months > 0) {
date_sub($date_start, date_interval_create_from_date_string($months . ' month'));
date_sub($date_end, date_interval_create_from_date_string($months . ' month'));
}
// date_sub($date_start, date_interval_create_from_date_string('1 month'));
date_sub($date_end, date_interval_create_from_date_string('1 day'));
$date_from = date_format($date_start, 'Ymd') . '000000';
$date_to = date_format($date_end, 'Ymd') . '235959';
date_sub($date_start, date_interval_create_from_date_string('1 month'));
date_sub($date_end, date_interval_create_from_date_string('1 month'));
$last_from = date_format($date_start, 'Ymd') . '000000';
$last_to = date_format($date_end, 'Ymd') . '235959';
$return = array();
$return['0'] = $date_from;
$return['1'] = $date_to;
$return['2'] = $last_from;
$return['3'] = $last_to;
return $return;
}
示例15: notify_payment
public function notify_payment()
{
$this->load->model('client_model');
$this->load->model('bill_model');
$received_data = $this->input->post();
$user_name = $this->session->userdata('username');
$get_email = $this->client_model->get_email_id($user_name);
$get_balance = $this->bill_model->get_balance($received_data["invoice"], $get_email);
$balance = floatval($get_balance[0]['balance']) - floatval($received_data["mc_gross_1"]);
// echo $get_balance[0]['balance']."<br/>".$received_data["mc_gross_1"]."<br/>".$balance;
$data = array("transaction_id" => $received_data["txn_id"], "gateway" => "Paypal", 'bill_id' => $received_data["invoice"], "user_email" => $get_email, "credit" => $received_data["mc_gross_1"], "vat" => $received_data['mc_gross_2'], "balance" => $balance, "transaction_date_time" => $received_data["payment_date"]);
$this->bill_model->insert_transaction($data);
$partial_status = 0;
$bill_due_date = $this->bill_model->bill_due_date($received_data["invoice"]);
if ($balance > 0) {
$date = date_create($bill_due_date[0]['bill_due_date']);
date_add($date, date_interval_create_from_date_string("15 days"));
$bill_date = date_format($date, "Y-m-d");
$data = array("bill_due_date" => $bill_date, "bill_allow_partial" => 0, "bill_to_paid" => $bill_due_date[0]["bill_to_paid"] + $received_data["mc_gross_1"], 'bill_due_amount' => $balance, "partial_status" => 1);
$data1 = array("status" => 1);
$this->bill_model->update_bill($data, $received_data["invoice"]);
$this->bill_model->update_bill_service($data1, $received_data["invoice"]);
} else {
$data = array("bill_to_paid" => $bill_due_date[0]["bill_to_paid"] + $received_data["mc_gross_1"], 'bill_due_amount' => $balance, "bill_status" => 1);
$data1 = array("status" => 1);
$this->bill_model->update_bill($data, $received_data["invoice"]);
$this->bill_model->update_bill_service($data1, $received_data["invoice"]);
}
$data = array("transaction_id" => $received_data["txn_id"], "gateway" => "Paypal", 'bill_id' => $received_data["invoice"], "balance" => $balance, "credit" => $received_data["mc_gross_1"], "transaction_date_time" => $received_data["payment_date"]);
$this->session->set_userdata($data);
redirect('/client/view_bill_details/' . $received_data["invoice"]);
}