本文整理汇总了PHP中date_modify函数的典型用法代码示例。如果您正苦于以下问题:PHP date_modify函数的具体用法?PHP date_modify怎么用?PHP date_modify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了date_modify函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: week2period
function week2period($annee, $semaine)
{
$lundi = new DateTime();
$lundi->setISOdate($annee, $semaine);
$dimanche = new DateTime();
$dimanche->setISOdate($annee, $semaine);
date_modify($dimanche, '+27 day');
$date = $lundi->diff($dimanche);
$dimanche = $dimanche->modify('+1 day');
$interval = new DateInterval('P1D');
$daterange = new DatePeriod($lundi, $interval, $dimanche);
setlocale(LC_TIME, 'fr_FR.utf8', 'fra');
$cleNbSemaine = $semaine;
$jours = [];
$nbJours = 0;
foreach ($daterange as $date) {
if ($date->format("w") != 0 && $date->format("w") != 6) {
$jour = strftime("%A", $date->getTimestamp());
$mois = strftime("%B", $date->getTimestamp());
$cle = $date->format('d') . $date->format('m') . $date->format('Y');
$jours[$cleNbSemaine][$cle] = $jour . ' ' . $date->format("d") . ' ' . $mois . ' ' . $date->format('Y');
$nbJours++;
if ($nbJours == 5) {
$nbJours = 0;
$cleNbSemaine++;
}
}
}
return $jours;
}
示例2: add_objectives
public function add_objectives(Request $request)
{
$week_of = \DateTime::createFromFormat('Y-m-d', $request->week_of);
$objectives = $request->objective;
$lessons = array();
foreach ($objectives as $key1 => $objective) {
foreach ($objective as $key => $val) {
$temp = clone $week_of;
switch ($key) {
case 'monday':
date_modify($temp, '+0 days');
break;
case 'tuesday':
date_modify($temp, '+1 day');
break;
case 'wednesday':
date_modify($temp, '+2 days');
break;
case 'thursday':
date_modify($temp, '+3 days');
break;
case 'friday':
date_modify($temp, '+4 days');
break;
}
$objective = new \App\Objective();
$objective->section_id = str_replace('s_', '', $key1);
$objective->user_id = 1;
$objective->lesson_date = date_format($temp, 'Y-m-d');
$objective->objective = $val;
$objective->save();
}
}
}
示例3: brandcsvAction
public function brandcsvAction()
{
Mage::getSingleton('core/session')->setParameter('second');
$this->loadLayout();
$status = $this->getRequest()->getPost('status');
$fromDate = $this->getRequest()->getPost('from');
$toDate = $this->getRequest()->getPost('to');
$toDate = date_create($toDate);
date_modify($toDate, '+1 day');
$toDate = $toDate->format('Y-m-d');
if ($status == 'pending') {
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('pending')));
} elseif ($status == 'process') {
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('processing')));
} elseif ($status == 'both') {
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('pending', 'processing')));
} elseif ($status == 'all') {
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate));
}
foreach ($orders as $order) {
$orderIds[] = $order->getIncrementId();
}
Mage::register('orderIds', $orderIds);
$this->renderLayout();
}
示例4: performaAction
public function performaAction()
{
Mage::getSingleton('core/session')->setParameter('second');
$this->loadLayout();
$status = $this->getRequest()->getPost('stsatus');
$fromDate = $this->getRequest()->getPost('from');
$toDate = $this->getRequest()->getPost('to');
$toDate = date_create($toDate);
date_modify($toDate, '+1 day');
$toDate = $toDate->format('Y-m-d');
if ($status == 'pending') {
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('pending')));
} elseif ($status == 'process') {
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('processing')));
} elseif ($status == 'both') {
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate))->addFieldToFilter('status', array('in' => array('pending', 'processing')));
} elseif ($status == 'all') {
$orders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate));
}
foreach ($orders as $order) {
$addressDetails = $order->getShippingAddress()->getData();
$orderData[] = array('id' => $order->getIncrementId(), 'customer' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), 'address' => $addressDetails['street'], 'city' => $addressDetails['city'], 'phone' => $order->getShippingAddress()->getTelephone(), 'weight' => '450', 'price' => $order->getGrandTotal(), 'email' => $order->getCustomerEmail());
}
Mage::register('orderData', $orderData);
$this->renderLayout();
}
示例5: tgl_jatuh_tempo
public function tgl_jatuh_tempo($tgl_invoice)
{
$jarak_hari = 15;
$date = date_create($tgl_invoice);
date_modify($date, "+ " . $jarak_hari . " days");
$tgl_jatuh_tempo = date_format($date, "Y-m-d");
return $tgl_jatuh_tempo;
}
示例6: addHoliday
public function addHoliday($date_from, $date_to = '', $calendar_id)
{
global $wpdb;
global $blog_id;
$blog_prefix = $blog_id . "_";
if ($blog_id == 1) {
$blog_prefix = "";
}
if ($date_to == '') {
//check if this day already exists
$numrows = $wpdb->query($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_holidays WHERE holiday_date =%s AND calendar_id= %d", $date_from, $calendar_id));
if ($numrows > 0) {
return 0;
} else {
$wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->base_prefix . $blog_prefix . "booking_holidays (holiday_date,calendar_id) VALUES(%s,%d)", $date_from, $calendar_id));
$lastId = $wpdb->insert_id;
//check if there are reservation for that date
$checkQry = $wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_reservation r INNER JOIN " . $wpdb->base_prefix . $blog_prefix . "booking_slots s ON s.slot_id = r.slot_id WHERE s.slot_date = %s AND r.calendar_id = %d", $date_from, $calendar_id);
$checkRows = $wpdb->query($checkQry);
if ($checkRows > 0) {
$wpdb->query($wpdb->prepare("UPDATE " . $wpdb->base_prefix . $blog_prefix . "booking_slots SET slot_active = %d WHERE slot_date=%s AND calendar_id = %d", 0, $date_from, $calendar_id));
} else {
$wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->base_prefix . $blog_prefix . "booking_slots WHERE slot_date = %s AND calendar_id= %d", $date_from, $calendar_id));
}
return $lastId;
}
} else {
$arrNewIds = array();
$datefromnum = str_replace("-", "", $date_from);
$datetonum = str_replace("-", "", $date_to);
$date = date_create($date_from);
while ($datefromnum <= $datetonum) {
$dateformat = date_format($date, 'Y-m-d');
//check if this day already exists
$holidayCheck = $wpdb->query($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_holidays WHERE holiday_date =%s AND calendar_id= %d", $dateformat, $calendar_id));
if ($holidayCheck == 0) {
$wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->base_prefix . $blog_prefix . "booking_holidays (holiday_date,calendar_id) VALUES(%s,%d)", $dateformat, $calendar_id));
array_push($arrNewIds, $wpdb->insert_id);
//check if there are reservation for that date
$check = $wpdb->query($wpdb->prepare("SELECT * FROM " . $wpdb->base_prefix . $blog_prefix . "booking_reservation r INNER JOIN " . $wpdb->base_prefix . $blog_prefix . "booking_slots s ON s.slot_id = r.slot_id WHERE s.slot_date = %s AND r.calendar_id = %d", $dateformat, $calendar_id));
if ($check > 0) {
$wpdb->query($wpdb->prepare("UPDATE " . $wpdb->base_prefix . $blog_prefix . "booking_slots SET slot_active = %d WHERE slot_date=%s AND calendar_id = %d", 0, $dateformat, $calendar_id));
} else {
$wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->base_prefix . $blog_prefix . "booking_slots WHERE slot_date = %s AND calendar_id=%d", $dateformat, $calendar_id));
}
}
if (function_exists("date_add")) {
date_add($date, date_interval_create_from_date_string('1 days'));
} else {
date_modify($date, '+1 day');
}
//date_modify($date, '+1 day');
$datefromnum = date_format($date, 'Ymd');
}
return $arrNewIds;
}
}
示例7: getItems
public static function getItems($period, $user, $yachs = 'ntime', $sport = '*', $currentpage = 'weekpage')
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.id,a.tdate, sc.sport_abbr as sport , a.method, a.description, a.comment, a.location,a.competition,' . 'sum( i.km ) AS km, sum( i.climb ) AS climb, sum( i.etime ) AS etime, sum( i.ntime ) AS ntime,' . 'sum(i.' . $yachs . '*(c.group=1)) as RECOM,sum(i.' . $yachs . '*(c.group=2)) as GA1,sum(i.' . $yachs . '*(c.group=3)) as KA1,' . 'sum(i.' . $yachs . '*(c.group=4)) as GA2,sum(i.' . $yachs . '*(c.group=5)) as KA2,sum(i.' . $yachs . '*(c.group=6)) as WSA,' . 'sum(i.' . $yachs . '*(c.group=0)) as Alt');
$query->from($db->quoteName('#__htraininglogs_tr_sessions') . ' AS a');
$query->leftjoin($db->quoteName('#__htraininglogs_tr_splittimes') . ' AS s ON a.id = s.tr_id');
$query->leftjoin($db->quoteName('#__htraininglogs_tr_intensitylevels') . 'as i ON (s.id = i.split_id) AND (i.state = 1)');
$query->leftjoin($db->quoteName('#__htraininglogs_cfg_sport') . 'AS sc ON a.sport_id = sc.id');
$query->leftjoin($db->quoteName('#__htraininglogs_cfg_intensity') . ' AS c ON i.int_id = c.id');
if ($sport != '*') {
$query->where('a.sport_id in (' . $sport . ')');
}
$query->where('a.user_id = ' . $user->id);
$query->where('a.state = 1');
$query->where('a.tdate BETWEEN "' . $period->anfdatback->format('Y-m-d') . ' 0:00:00" AND "' . $period->enddat->format('Y-m-d') . ' 23:59:59"');
$query->group('a.id,a.tdate,sport, a.method, a.description, a.comment, a.location,a.competition');
$query->order('a.tdate ASC');
$db->setQuery($query);
$items = $db->loadObjectlist();
$i = 0;
$k = -$period->backviewdays;
$itemsfull = array();
$dat = new DateTime($period->anfdatback->format('Y-m-d'));
while ($dat <= $period->enddat) {
if ($items[$i] and $dat->format('Y-m-d') == JFactory::getDate($items[$i]->tdate)->format('Y-m-d')) {
while ($items[$i] and $dat->format('Y-m-d') == JFactory::getDate($items[$i]->tdate)->format('Y-m-d')) {
$itemsfull[$k++] = $items[$i++];
}
} else {
$itemsfull[$k] = new stdClass();
$itemsfull[$k]->id = 0;
$itemsfull[$k]->tdate = $dat->format('Y-m-d');
$itemsfull[$k]->sport = '';
$itemsfull[$k]->method = '';
$itemsfull[$k]->location = '';
$itemsfull[$k]->description = '';
$itemsfull[$k]->comment = '';
$itemsfull[$k]->competition = 0;
$itemsfull[$k]->km = 0;
$itemsfull[$k]->climb = 0;
$itemsfull[$k]->etime = 0;
$itemsfull[$k]->ntime = 0;
$itemsfull[$k]->RECOM = 0;
$itemsfull[$k]->GA1 = 0;
$itemsfull[$k]->KA1 = 0;
$itemsfull[$k]->GA2 = 0;
$itemsfull[$k]->KA2 = 0;
$itemsfull[$k]->WSA = 0;
$itemsfull[$k++]->Alt = 0;
}
$dat = date_modify($dat, '+1 day');
}
// print_r($itemsfull);exit;
return $itemsfull;
}
示例8: setUp
public function setUp()
{
$this->dayDates = array('today' => $today = new \DateTime(), 'yesterday' => date_modify(clone $today, '-1 day'), 'tomorrow' => date_modify(clone $today, '+1 day'), 'day after tomorrow' => date_modify(clone $today, '+2 days'));
$storage = new \SplObjectStorage();
$storage[$this->dayDates['today']] = 'today';
$storage[$this->dayDates['yesterday']] = 'yesterday';
$storage[$this->dayDates['tomorrow']] = 'tomorrow';
$this->storage = $storage;
// Assume we have map with 3 pairs.
$this->dayNames = new PairMap(new SplObjectStoragePairs($storage));
}
示例9: get_status_for_instrument_over_range
/**
* Return a set of status items for a list of instruments over a given
* range of times.
*
* @param array $instrument_list The list of instruments to use in this query this query
* this query
* @param string $time_period a strtotime() parseable relative datetime object specifier datetime object specifier
* datetime object specifier
*
* @return array
*
* @author Ken Auberry <kenneth.auberry@pnnl.gov>
*/
public function get_status_for_instrument_over_range($instrument_list, $time_period = '1 day')
{
$current_time_obj = new DateTime();
if (strtotime($time_period)) {
$current_time_obj->setTime($current_time_obj->getHours(), 0, 0);
$start_time = date_modify($current_time_obj, "-{$time_period}");
} else {
$start_time = $current_time_obj;
}
return $this->get_status_for_instrument_before_date($instrument_list, $start_time);
}
示例10: reminderAddReasonToManager
function reminderAddReasonToManager($data)
{
if (!empty($data)) {
$userObj = new rating();
$pending_count = 0;
$lead_name = "Lead";
$subject = "Parakh - You have <PENDING_COUNT> pending ratings.";
$message_template .= "Dear <LEAD_NAME>," . NEWLINE . NEWLINE;
$due_date = date('Y-m-d 23:59:59', strtotime("+10 days"));
$message_template .= "You have rated the following team member(s) without providing rating reason. We request you to add a reason to your rating, else the ratings will be reverted." . NEWLINE . NEWLINE;
$message_template .= "<table width='70%' border='0' cellpadding='4' cellspacing='1'><tr style='background-color:#0099CC;color:#FFF'><td>Team Member</td><td>Rating</td><td>Rating On</td><td>Expires On</td><tr>";
$message = "";
$total_record = count($data);
for ($i = 0; $i < $total_record;) {
$bgcolor = $i % 2 == 0 ? "#FFFFFF" : "#87CEEB";
$message .= "<tr style='background-color:" . $bgcolor . ";'>";
$message .= "<td>" . $data[$i]["tm_name"] . "</td>";
$message .= "<td>" . ($data[$i]["rating"] == 1 ? "+1" : " -1") . "</td>";
$date_tobe_formatted = @date_create($data[$i]["created_date"]);
$create_on = @date_format($date_tobe_formatted, "jS F, Y h:iA");
$expire_date = @date_modify($date_tobe_formatted, '+10 day');
$expire_date = @date_format($expire_date, "jS F, Y");
$message .= "<td>" . $create_on . "</td>";
$message .= "<td>" . $expire_date . "</td>";
$message .= "</tr>";
$pending_count++;
if ($data[$i]["given_by"] !== $data[$i + 1]["given_by"] || $i == $total_record - 1) {
$message .= "</table>";
$lead_name = $userObj->get_user_full_name($data[$i]['given_by']);
$to["name"] = $lead_name;
$lead_name = explode(" ", trim($lead_name));
$lead_name = $lead_name[0];
$message = $message_template . $message;
$message .= NEWLINE;
$message .= EMAIL_FOOTER;
$to["email"] = $userObj->get_user_email($data[$i]['lead_id']);
$subject = str_replace('<PENDING_COUNT>', $pending_count, $subject);
$message = str_replace('<LEAD_NAME>', $lead_name, $message);
if (ENVIRONMENT != 'LIVE') {
$to["email"] = LEAD_EMAIL;
}
smtp_send_mail($to, $subject, $message);
$pending_count = 0;
$message = '';
$i++;
continue;
}
$i++;
}
} else {
echo 'No records found to send reminder email.<BR/><BR/>';
}
}
示例11: diff
/**
* Take the difference of two datetime ranges
*
* The difference of two datetime ranges in this case means that the overlap of
* the two ranges will be removed from the first range, and the result will
* be returned.
*
* This method will refuse to bisect the current datetime range (thus,
* confusingly, creating two datetime ranges), so the argument datetime range must
* begin prior to and end during the current datetime range, or begin during and
* end after the current datetime range.
*
* @param DateRange|DateTimeRange $arg Other DateRange or DateTimeRange to test
*
* @return DateTimeRange
* @throws OutOfRangeException
*/
public function diff(DateRange $arg)
{
if (!$this->overlaps($arg)) {
throw new OutOfRangeException('Argument must overlap this range');
}
if ($this->getStart() < $arg->getStart() && $this->getEnd() > $arg->getEnd()) {
throw new OutOfRangeException('Argument must not be exclusively contained within this range');
}
if ($this->getStart() < $arg->getStart()) {
return new static(clone $this->getStart(), date_modify(clone $arg->getStart(), '-1 second'));
}
return new static(date_modify(clone $arg->getEnd(), '+1 second'), clone $this->getEnd());
}
示例12: local_to_GMT_data
/**
* convert data from local to GMT
* TODO handle solar and legal time where is present.
*/
function local_to_GMT_data($local_data)
{
$GMT_data = $local_data;
if (!empty($local_data)) {
$config = JFactory::getConfig();
$offset = $config->get('config.offset');
$offset = 0 - $offset;
$date = date_create($local_data);
date_modify($date, $offset . ' hour');
$GMT_data = date_format($date, 'Y-m-d H:i:s');
}
return $GMT_data;
}
示例13: get_trips
function get_trips($trip_date)
{
global $DB;
$before_date = date_create($trip_date);
$after_date = date_create($trip_date);
date_modify($before_date, '-1 day');
date_modify($after_date, '+1 day');
echo date_format($before_date, 'Y-m-d');
echo date_format($after_date, 'Y-m-d');
$req = $DB->prepare("SELECT * \r\n\t\t\t\t\t\t\tFROM trips\r\n\t\t\t\t\t\t\tWHERE departure BETWEEN :before_date AND :after_date\r\n\t\t\t\t\t\t\t\tAND available_sits > 0\r\n\t\t\t\t\t\t\tORDER BY departure") or die(print_r($req->errorInfo()));
$req->execute(array('before_date' => date_format($before_date, 'Y-m-d'), 'after_date' => date_format($after_date, 'Y-m-d')));
$trips = $req->fetchAll();
return $trips;
}
示例14: _getData
/**
* Override parent::_getData() to insert groupBy and orderBy clauses into query
*
* @return unknown_type
*/
function _getData()
{
$state = $this->_getState();
$order_states = array('3', '5', '17');
$filter_date_from = $state['filter_date_from'];
$filter_date_to = $state['filter_date_to'];
if (empty($filter_date_to) and empty($filter_date_from)) {
$date = JFactory::getDate();
$today = $date->toFormat("%Y-%m-%d 00:00:00");
$filter_date_to = $today;
$database = JFactory::getDBO();
$query = " SELECT DATE_SUB('" . $today . "', INTERVAL 1 MONTH) ";
$database->setQuery($query);
$filter_date_from = $database->loadResult();
} else {
if (empty($filter_date_to) and !empty($filter_date_from)) {
$filter_date_to = $filter_date_from;
} else {
if (!empty($filter_date_to) and empty($filter_date_from)) {
$filter_date_from = $filter_date_to;
}
}
}
$date_tmp = date_create($filter_date_to);
date_modify($date_tmp, '24 hour');
$database = JFactory::getDBO();
$curdate = TiendaHelperBase::local_to_GMT_data($filter_date_from);
$enddate = TiendaHelperBase::local_to_GMT_data(date_format($date_tmp, 'Y-m-d H:i:s'));
while ($curdate < $enddate) {
// set working variables
$variables = TiendaHelperBase::setDateVariables($curdate, $enddate, 'daily');
$thisdate = $variables->thisdate;
$nextdate = $variables->nextdate;
$query = new TiendaQuery();
$query->select('COUNT(tbl.order_id) AS num, SUM(order_total) AS amount');
$query->from('#__tienda_orders AS tbl');
$query->where("tbl.order_state_id IN (" . $this->getStatesCSV() . ")");
$query->where("tbl.modified_date >= '" . $curdate . "'");
$query->where("tbl.modified_date <= '" . $nextdate . "'");
$database->setQuery((string) $query);
$return_daily_report = $database->loadObject();
$date_tmp = date_create(TiendaHelperBase::GMT_to_local_data($curdate));
$data_print = date_format($date_tmp, 'd-m-Y');
$return_range_report->{$data_print} = $return_daily_report;
// increase curdate to the next value
$curdate = $nextdate;
}
return $return_range_report;
}
示例15: getSalaryDate
/**
* Retrieve the date on which salaries should be paid for this specific month
* Will return null if no salaries should be paid
* @return \DateTime|null
*/
private function getSalaryDate()
{
// Get last day of month
$clone = clone $this->currentDate;
$lastDay = $clone->modify('last day of this month');
// If last day of month is a weekend, pay the friday beforehand
if ($this->isWeekend($lastDay)) {
$lastDay = date_modify($lastDay, 'previous friday');
}
// Return null if salary has already been paid this month
if ($this->currentDate > $lastDay) {
return null;
}
return $lastDay;
}