本文整理汇总了PHP中date_interval_create_from_date_string函数的典型用法代码示例。如果您正苦于以下问题:PHP date_interval_create_from_date_string函数的具体用法?PHP date_interval_create_from_date_string怎么用?PHP date_interval_create_from_date_string使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了date_interval_create_from_date_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_date_sub
function test_date_sub()
{
$datetime = date_create("2010-08-16");
$interval = date_interval_create_from_date_string("2 weeks");
$dt2 = date_sub($datetime, $interval);
return date_format($dt2, "Y-m-d");
}
示例2: jireRest
public function jireRest(Request $request)
{
try {
//$jira_rest = \Drupal::service('jira_rest.jira_rest_service');
$container = \Drupal::getContainer();
$jira = JiraRestController::create($container);
$author_name = $jira->config('jira_rest.settings')->get('jira_rest.username');
$interval = "-2d";
$res = $jira->jira_rest_searchissue("updated >= " . $interval . " AND assignee in (" . $author_name . ")");
} catch (JiraRestException $e) {
$responce['messages'][] = $e->getMessage();
}
$responce = array();
$interval = abs(intval($interval));
$sub_days = "{$interval} days";
$date = date_create();
$toDate = date_format($date, 'Y-m-d');
date_sub($date, date_interval_create_from_date_string($sub_days));
$fromDate = date_format($date, 'Y-m-d');
foreach ($res->issues as $issue) {
$worklog = $jira->jira_rest_get_worklog($issue->key);
foreach ($worklog->worklogs as $entry) {
$shortDate = substr($entry->started, 0, 10);
# keep a worklog entry on $key item,
# iff within the search time period
if ($entry->author->name == $author_name && $shortDate >= $fromDate && $shortDate <= $toDate) {
$responce[$issue->key] += $entry->timeSpentSeconds;
}
}
}
}
示例3: 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"]);
}
示例4: indexAction
public function indexAction(Request $request, SessionInterface $session)
{
if (Util::checkUserIsLoggedIn()) {
$loggedInUserId = $session->get('user/id');
$clientId = $session->get('client/id');
$clientSettings = $session->get('client/settings');
} else {
$loggedInUserId = null;
$clientId = $this->getRepository(UbirimiClient::class)->getClientIdAnonymous();
$clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
}
$projectId = $request->get('id');
$project = $this->getRepository(YongoProject::class)->getById($projectId);
if ($project['client_id'] != $clientId) {
return new RedirectResponse('/general-settings/bad-link-access-denied');
}
$currentDate = Util::getServerCurrentDateTime();
$dateFrom = date_create(Util::getServerCurrentDateTime());
$dateTo = date_format(date_create(Util::getServerCurrentDateTime()), 'Y-m-d');
date_sub($dateFrom, date_interval_create_from_date_string('1 months'));
$dateFrom = date_format($dateFrom, 'Y-m-d');
$issueQueryParameters = array('project' => array($projectId), 'resolution' => array(-2));
$issues = $this->getRepository(Issue::class)->getByParameters($issueQueryParameters, $loggedInUserId, null, $loggedInUserId);
$hasGlobalAdministrationPermission = $this->getRepository(UbirimiUser::class)->hasGlobalPermission($clientId, $loggedInUserId, GlobalPermission::GLOBAL_PERMISSION_YONGO_ADMINISTRATORS);
$hasGlobalSystemAdministrationPermission = $this->getRepository(UbirimiUser::class)->hasGlobalPermission($clientId, $loggedInUserId, GlobalPermission::GLOBAL_PERMISSION_YONGO_SYSTEM_ADMINISTRATORS);
$hasAdministerProjectsPermission = $this->getRepository(UbirimiClient::class)->getProjectsByPermission($clientId, $loggedInUserId, Permission::PERM_ADMINISTER_PROJECTS);
$hasAdministerProject = $hasGlobalSystemAdministrationPermission || $hasGlobalAdministrationPermission || $hasAdministerProjectsPermission;
$sectionPageTitle = $clientSettings['title_name'] . ' / ' . SystemProduct::SYS_PRODUCT_YONGO_NAME . ' / ' . $project['name'] . ' / Reports';
$menuSelectedCategory = 'project';
return $this->render(__DIR__ . '/../../Resources/views/project/ViewReportsSummary.php', get_defined_vars());
}
示例5: page
/**
* Loads a page in the registration process
* Page 1 = Login information
* Page 2 = Profile information
* Page 3 = Profile information
* Page 4 = Confirm information
* @param $page int requested page number
*/
public function page($page)
{
if (!isset($page)) {
$page = 0;
}
if ($page == 1) {
$this->view->title = 'Login information';
$this->view->render('register/authenticationInfo');
} elseif ($page == 2) {
$this->view->title = 'Profile information';
$this->view->genders = $this->model->getGenders();
$this->view->maxDate = date_sub(date_create(), date_interval_create_from_date_string('13 years'));
$this->view->minDate = date_sub(date_create(), date_interval_create_from_date_string('101 years'));
$this->view->render('register/userInfo');
} elseif ($page == 3) {
$this->view->title = 'Profile information';
$this->view->countries = $this->model->getCountries();
$this->view->render('register/addressInfo');
} elseif ($page == 4) {
$this->view->title = 'Confirm information';
if (isset($this->newUser['gender_id'])) {
$this->view->gender = $this->model->getGender($this->newUser['gender_id']);
}
if (isset($this->newUser['country'])) {
$this->view->country = $this->model->getCountry($this->newUser['country']);
}
$this->view->canSubmit = $this->validate();
$this->view->render('register/regConfirm');
} else {
$this->view->render('register/index');
}
}
示例6: 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()));
}
示例7: sendmailAction
public function sendmailAction()
{
//Print header for log
echo "********************\n";
echo "sendmailAction START\n";
echo date('Y-m-d H:i:s e') . "\n";
echo "********************\n";
//Initialize variables
$sm = $this->getServiceLocator();
$books = new Books($sm);
$users = new Users($sm);
$mailler = new Mailler($sm);
//Get new books from last week
$lastDate = date("o-m-d", date_sub(new DateTime(), date_interval_create_from_date_string("7 days"))->getTimestamp());
$bookList = $books->listBooks(array("sql" => "date >= '{$lastDate}'"))->toArray();
//Print list of new books
echo "LIST OF BOOKS:\n";
foreach ($bookList as $book) {
echo "\t" . $book['title'] . "\n";
}
//Get list of subscribed users
$userList = $users->listUsers("weeklynews = 1")->toArray();
//Print list of subscribed users
echo "LIST OF EMAILS:\n";
foreach ($userList as $user) {
echo "\t" . $user['email'] . "\n";
}
//Send mails if there is at least one new book
if (count($bookList) > 0) {
$mailler->newsletterEmail($userList, $bookList, date("d/m/o"));
}
die;
}
示例8: 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]);
}
示例9: beforeFilter
public function beforeFilter()
{
// if($this->Auth->user('role') != 'admin'){
// $this->Session->setFlash('No esta autorizado a consultar esa pagina');
// $this->redirect(array('controller' => 'application', 'action' => 'detail','addon.simplylock.theme.example'));
// die();
// }
//algunas cosas de aca se tienen que validar en el metodo como es el caso del upload cuando este
$this->Auth->allow('logout');
// if ($this->Session->check('Config.language')) {
// Configure::write('Config.language', $this->Session->read('Config.language'));
// }
// else{
// Configure::write('Config.language', 'esp');
// }
$this->set('logged_in', $this->Auth->loggedIn());
$this->set('userAutenticated', $this->Auth->user());
$this->set('isadmin', $this->Auth->user()['role'] == 'admin' ? 1 : 0);
//data for menu
//put data en la pagina
$config = $this->Configuration->find('first', array('conditions' => array('Configuration.id' => 1)));
$dayToNew = $config['Configuration']['days_to_new'];
$date = date_create('now');
date_sub($date, date_interval_create_from_date_string($dayToNew . ' days'));
$settings = array('conditions' => array('Application.created >= "' . $date->format('Y-m-d H:i:s') . '"'));
$cantNew = $this->Application->find('count', $settings);
$settings1 = array('conditions' => array('Application.recommended ' => 1));
$cantRecomended = $this->Application->find('count', $settings1);
$settings1 = array('conditions' => array('Application.verificate ' => 1));
$cantverificate = $this->Application->find('count', $settings1);
$this->set('cantnews', $cantNew);
$this->set('recommended', $cantRecomended);
$this->set('verificate', $cantverificate);
}
示例10: getOfficeCampaignBeginDate
public static function getOfficeCampaignBeginDate($date = null)
{
$end_date = self::getOfficeCampaignEndDate($date);
$start_date = clone $end_date;
$start_date->sub(date_interval_create_from_date_string('1 month'));
return $start_date;
}
示例11: setDefaultDatesFromRequest
private function setDefaultDatesFromRequest($event, Request $request)
{
$event->setStart($this->getStartDateFromRequest($request));
$end = clone $event->getStart();
$end->add(date_interval_create_from_date_string('1 hour'));
$event->setEnd($end);
}
示例12: finanzas
public function finanzas()
{
$user = \Auth::User();
$now = new \DateTime();
$lasth_month = date_add($now, date_interval_create_from_date_string("-1 months"));
$now = new \DateTime();
$last_last_month = date_add($now, date_interval_create_from_date_string("-2 months"));
$now = new \DateTime();
//\DB::select("delete from comisiones where periodo <> extract(year_month from ?) and periodo <> extract(year_month from ?) and periodo <> extract(year_month from ?)", [$now, $lasth_month, $last_last_month]);
if (!$user->isContabilidad) {
$distribuidores = [];
$subdistribuidores = [];
if ($user->isAdmin) {
$distribuidores = \DB::table('users')->get();
foreach ($distribuidores as $distribuidor) {
$subdistribuidores[$distribuidor->name] = \DB::table('subdistribuidores')->where('emailDistribuidor', $distribuidor->email)->get();
}
} else {
$subdistribuidores = \DB::table('subdistribuidores')->where('emailDistribuidor', $user->email)->get();
}
$periodos = \DB::select("select distinct periodo from comisiones order by periodo desc");
return view('/finanzas', array('user' => $user, 'subdistribuidores' => $subdistribuidores, 'distribuidores' => $distribuidores, 'periodos' => $periodos));
} else {
$distribuidores = \DB::table('users')->where('name', '<>', 'OFICINA')->get();
foreach ($distribuidores as $distribuidor) {
$subdistribuidores[$distribuidor->name] = \DB::table('subdistribuidores')->where('emailDistribuidor', $distribuidor->email)->get();
}
$periodos = \DB::select("select distinct periodo from comisiones order by periodo desc");
return view('/finanzas', array('user' => $user, 'subdistribuidores' => $subdistribuidores, 'distribuidores' => $distribuidores, 'periodos' => $periodos));
}
}
示例13: getMySQLFormat
function getMySQLFormat($dateTime, $round = 0)
{
// format as YYYY-MM-DD HH:MM:SS
$formatstr = $dateTime->format('Y-m-d H:i:s');
// check if round is -1 to round down
if ($round == -1) {
// get the minutes
$minutes = date_parse($formatstr)['minute'];
// check if it already is at the nearest hour (if minutes = 0)
if ($minutes != 0) {
// subtract the minutes
$dateTime->sub(date_interval_create_from_date_string("{$minutes} minutes"));
// reset the string
$formatstr = $dateTime->format('Y-m-d H:i:s');
}
// check if round is 1 to round up
} else {
if ($round == 1) {
// get the minutes
$minutes = date_parse($formatstr)['minute'];
// check if it already is at the nearest hour (if minutes = 0)
if ($minutes != 0) {
// determine the minutes to be added
$minutes = 60 - $minutes;
// add the minutes
$dateTime->add(date_interval_create_from_date_string("{$minutes} minutes"));
// reset the string
$formatstr = $dateTime->format('Y-m-d H:i:s');
}
}
}
// return the formatted string
return $formatstr;
}
示例14: 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;
}
示例15: 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;
}
}