function umur($tgl_lahir) { $thn_lahir = date_format(date_create($tgl_lahir), 'Y'); $thn_skrg = date('Y'); $umur = $thn_skrg - $thn_lahir; return $umur; }
public function detalleOrden($codigo, $parametro) { $o_LTesoreria = new LTesoreria(); $o_LPersona = new LPersona(); $combo = $this->comboTipoDocumento('1'); $arrayDatos = $o_LTesoreria->datosPersonales($codigo, $parametro); //$codigo=''; $nombre = ''; $fechaNacimiento = ''; $edad = ''; $documento = ''; $filiacion = ''; //print_r($arrayDatos); foreach ($arrayDatos as $fila) { //$codigo=$fila[0]; $nombre = htmlentities($fila[4] . " " . $fila[5] . ", " . $fila[6]); $fechaNacimiento = $fila[7]; $documento = $fila[0]; $filiacion = $fila[3]; } //date_default_timezone_set('Europe/London'); $datetime = date_create($fechaNacimiento); $fechaNacimiento = date_format($datetime, 'm/d/Y'); //echo date_format($datetime, DATE_ATOM); //echo $fechaNacimiento->format('d-m-y'); //print_r($arrayDatos); $edad = $o_LPersona->formatoEdad($fechaNacimiento); //creando la tabla $arrayFilas = $o_LTesoreria->obtenerOrdenes($codigo, $parametro); $arrayTipo = array("10" => "h", "0" => "c", "1" => "c", "2" => "c", "11" => "h", "3" => "c", "13" => "h", "4" => "c", "5" => "c", "6" => "c", "12" => "c", "7" => "c"); $arraycabecera = array("10" => " ", "0" => "Nro Orden", "1" => "Fecha", "2" => "Filiación", "11" => " ", "3" => "concepto", "13" => "Nro Comp.", "4" => "Precio", "5" => "Cant.", "6" => "Total", "12" => "....", "7" => "es"); $arrayColorEstado = array("1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9"); $o_Html = new Tabla1($arraycabecera, 15, $arrayFilas, 'tablaOrden', 'filax', 'filay', 'filaSeleccionada', 'onClick', '', 5, $arrayTipo, 7, $arrayColorEstado); require_once "../../cvista/tesoreria/detalleOrden.php"; }
/** * __construct Contructor that prepare the collection for assign product list * @var Int $userId Current logged seller id * @var String $filter Search query string * @var String $filter_prostatus product status query string * @var String filter_data_frm product creation from date query string * @var String filter_data_to product creation to date query string * @var Object $collection Catalog product collection object * @var Array $products Catalog product ids * @var Object $collection Assign product collection object */ public function __construct() { parent::__construct(); $userId = Mage::getSingleton('customer/session')->getCustomerId(); $filter = $this->getRequest()->getParam('s') != "" ? $this->getRequest()->getParam('s') : ""; $filter_prostatus = $this->getRequest()->getParam('prostatus') != "" ? $this->getRequest()->getParam('prostatus') : ""; $filter_data_frm = $this->getRequest()->getParam('from_date') != "" ? $this->getRequest()->getParam('from_date') : ""; $filter_data_to = $this->getRequest()->getParam('to_date') != "" ? $this->getRequest()->getParam('to_date') : ""; $from = null; $to = null; if ($filter_data_to) { $todate = date_create($filter_data_to); $to = date_format($todate, 'Y-m-d H:i:s'); } if ($filter_data_frm) { $fromdate = date_create($filter_data_frm); $from = date_format($fromdate, 'Y-m-d H:i:s'); } $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addFieldToFilter('name', array('like' => "%" . $filter . "%"))->setOrder('entity_id', 'AESC'); $products = array(); foreach ($collection as $data) { array_push($products, $data->getEntityId()); } $collection = Mage::getModel('mpassignproduct/mpassignproduct')->getCollection()->addFieldToFilter('product_id', array('in' => $products))->addFieldToFilter('created_at', array('datetime' => true, 'from' => $from, 'to' => $to))->addFieldToFilter('seller_id', array('eq' => $userId)); if ($filter_prostatus != "") { $collection->addFieldToFilter('flag', array('eq' => $filter_prostatus)); } $this->setCollection($collection); }
function dateDiff($s, $t) { $datetime1 = date_create($s); $datetime2 = date_create($t); $interval = date_diff($datetime1, $datetime2); return $interval->format('%R%a days'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $a = new \App\Popups(); $a->judul = Input::get('judul'); $a->slug = str_slug(Input::get('judul')); $a->deskripsi = Input::get('keterangan'); $a->tipe_valid = Input::get('type_valid'); if ($a->tipe_valid == "by_datetime" or $a->tipe_valid == "by_date") { $a->date_valid_start = date_format(date_create(Input::get('date_valid_start')), "Y-m-d"); $a->date_valid_end = date_format(date_create(Input::get('date_valid_end')), "Y-m-d"); } if ($a->tipe_valid == "by_datetime" or $a->tipe_valid == "by_time") { $a->time_valid_start = date_format(date_create(Input::get('time_valid_start')), "H:i:s"); $a->time_valid_end = date_format(date_create(Input::get('time_valid_end')), "H:i:s"); } if (Input::hasFile('image') and Input::file('image')->isValid()) { $image = date("YmdHis") . uniqid() . "." . Input::file('image')->getClientOriginalExtension(); Input::file('image')->move(storage_path() . '/popup_image', $image); $a->image = $image; } $a->keep_open = Input::get('keep_open'); $a->hotlink = Input::get('hotlink'); $a->idpengguna = Auth::user()->id; $a->save(); return redirect(url('admin/popups')); }
public function __construct($id = NULL, $name = NULL, $surname = NULL, $birthdate = NULL) { $this->id = $id; $this->name = $name; $this->surname = $surname; $this->birthdate = date_create($birthdate); }
public function testGetDatetimeObject() { $this->assertEquals(date_create('2 months ago'), $this->helper->getDatetimeObject('2 months ago')); $this->assertEquals(date_create('now'), $this->helper->getDatetimeObject(time())); $this->assertEquals(date_create('now'), $this->helper->getDatetimeObject()); $this->assertEquals(date_create('now'), $this->helper->getDatetimeObject(null)); }
/** * * @param type $manager * @param type $v */ public function populateDogodekSplosni($manager, $v) { $rep = $manager->getRepository('Koledar\\Entity\\DogodekSplosni'); $o = null; $nov = false; if (!$o) { $o = new \Koledar\Entity\DogodekSplosni(); $nov = true; } $o->setTitle($v[1]); $o->setStatus($v[2]); $date = empty($v[3]) ? null : date_create($v[3]); $o->setZacetek($date); $date = empty($v[4]) ? null : date_create($v[4]); $o->setKonec($date); $ref = $v[5] ? $this->getReference($v[5]) : null; $o->setProstor($ref); $ref = $v[6] ? $this->getReference($v[6]) : null; // $o->setSezona($ref); if ($nov) { $rep->create($o); } else { $rep->update($o); } $referenca = 'DogodekSplosni-' . $v[0]; // var_dump($referenca); $this->addReference($referenca, $o); $referencaDog = 'DogodekSpl-' . $v[0]; $this->addReference($referencaDog, $o->getDogodek()); }
private function currentDateTime() { date_default_timezone_set("Asia/Colombo"); $date = date_create(); $current_time = date_format($date, 'Y-m-d H:i:s'); return $current_time; }
public function getTimeDifference($otherDate) { $date1Timestamp = date_create($this->dayOfBirth); $date2Timestamp = date_create($otherDate); $diff = date_diff($date1Timestamp, $date2Timestamp); return $diff; }
/** * @param integer $monthInteger * @param string $format * @return bool|string */ public static function monthIntegerToString($monthInteger, $format = 'F') { if (is_string($monthInteger) && in_array(strtolower($monthInteger), self::$months)) { return $monthInteger; } return date_format(date_create("1/{$monthInteger}/2000"), $format); }
private function composeBirthday() { extract($this->properties); $day -= $day > 40 ? 40 : 0; $month -= $month > 40 ? 40 : 0; return date_create("{$century}{$year}-{$month}-{$day}"); }
public function __construct() { $this->idgroup = intval($this->idgroup); $this->groupmainactivity = intval($this->groupmainactivity); $this->groupcreatedate = date_create($this->groupcreatedate); $this->groupcreatoruserid = intval($this->groupcreatoruserid); }
private function createNinjaInvoice($publicId, $account, $client) { $invoice = new Invoice(); $invoice->account_id = $account->id; $invoice->user_id = $account->users()->first()->id; $invoice->public_id = $publicId; $invoice->client_id = $client->id; $invoice->invoice_number = $account->getNextInvoiceNumber(); $invoice->invoice_date = date_create()->format('Y-m-d'); $invoice->amount = PRO_PLAN_PRICE; $invoice->balance = PRO_PLAN_PRICE; $invoice->save(); $item = new InvoiceItem(); $item->account_id = $account->id; $item->user_id = $account->users()->first()->id; $item->public_id = $publicId; $item->qty = 1; $item->cost = PRO_PLAN_PRICE; $item->notes = trans('texts.pro_plan_description'); $item->product_key = trans('texts.pro_plan_product'); $invoice->invoice_items()->save($item); $invitation = new Invitation(); $invitation->account_id = $account->id; $invitation->user_id = $account->users()->first()->id; $invitation->public_id = $publicId; $invitation->invoice_id = $invoice->id; $invitation->contact_id = $client->contacts()->first()->id; $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH); $invitation->save(); return $invitation; }
public function age() { $bd = $this->patient->getOriginal('dateOfBirth'); $diagDate = $this->schedule->getOriginal('diagDate'); $age = date_diff(date_create($bd), date_create($diagDate))->y; return $age . ' ปี'; }
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; }
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(); }
protected function createDateTimeObject($value) { if ($value != '') { return date_create($value); } return null; }
public function createItemsHtml($program = '', $loja = '', $name = '', $endDate = '', $description = '', $title = '', $trackingLink = '', $firstCupomLoja) { $htmlItem = ''; $nameString = $this->revealName($program); //string usada nas imagens $nameCode = str_replace(" ", "-", $nameString); if ($firstCupomLoja) { $htmlItem .= '<h2 class="h-cupom" id="h-cupom-' . $nameString . '">Cupons ' . $program . '</h2>'; } $htmlItem .= '<div class="campo-cupom">'; $htmlItem .= '<span class="logo-cupom"><img src="/wp-content/themes/THEME/images/logo-cupom/cupom-de-desconto-logo-' . strtolower($nameCode) . '.jpg"></span>'; $htmlItem .= '<h3 class="titulo-cupom">' . $name . '</h3>'; $htmlItem .= '<a class="botao-cupom" data-title="' . title . '" data-heading="Aqui está seu cupom da ' . $nameString . '" data-subheading="' . $program . '" data-description="' . $description . '" href="' . $trackingLink . '" target="_blank"><img src="/wp-content/uploads/2015/12/botao-ver-cupom.jpg"></a>'; if (!empty($endDate)) { $endDate = explode('T', $endDate)[0]; $date = date_create($endDate); $endDate = date_format($date, "d/m/Y"); $htmlItem .= '<p class="prazo-cupom">Válido até ' . $endDate . '</p>'; } if (!empty($description)) { $htmlItem .= '<p class="info-cupom">Mais informações</p>'; $htmlItem .= '<div class="more-information more-information-hide"><span>Mais informações</span><br/>' . $description . '</div>'; } $htmlItem .= '</div>'; $html .= $htmlItem; return $html; }
public function getIndex(Request $r) { if (!isset($r->offset) || !isset($r->limit)) { $sql = RumputLaut::orderBy('id', 'desc')->first(); if ($sql) { // Jika sudah ada data // limit = Tanggal terbaru // offset = Limit - 3 bulan $limit1 = date_format(date_create($sql->created_at), "Y-m-d"); $limit = strtotime("{$limit1} +1 day"); $limit = date("Y-m-d", $limit); $offset = strtotime("{$limit1} -3 months"); $offset = date("Y-m-d", $offset); } else { // Jika belum ada data offset = tgl skrang, limit = offset + 3 bulan $offset = date('Y-m-d'); $limit = strtotime("{$offset} +3 months"); $limit = date("Y-m-d", $limit); } return redirect('/app/rumputlaut?offset=' . $offset . '&limit=' . $limit); } $limit = 10; $data['rumputlaut'] = RumputLaut::whereBetween('created_at', [$r->offset, $r->limit])->paginate($limit); return view('app.laporan-produksi.rumputlaut.index', $data)->with('limit', $limit); }
public function remove($id) { $fav = Favorite::where('StudentID', Auth::user()->StudentID)->where('FavoriteID', $id)->where('favorite', '1')->first(); $fav->favorite = 0; $fav->updated_at = date_timestamp_get(date_create()); $fav->save(); }
/** * Formatar data e hora * * @param string $data_hora string contendo uma representação de data ou hora * @param string $formato string contendo o formtado da data e/ou hora desejado. O farmato deve ser aceito pela * função date(); * * @return bool|mixed|string */ public static function formatarDataHora($data_hora, $formato) { # Se $formato estiver em branco retornar a data sem nenhum alteração if (empty($formato)) { return $data_hora; } // Fim if /* * Essas strings não serão aceitas, por se tratarem de datas e / ou horas inválidas */ $nao_aceito = ['0000-00-00', '0000-00-00 00:00:00']; if (!empty($data_hora) && !in_array($data_hora, $nao_aceito)) { # Se a string de data não foi válida para a conversão retorná-la com uma mensagem de erro if (!strtotime($data_hora)) { return "{$data_hora} - Data informada inválida"; } // Fim if /* * A função strtotime() não aceita a string da data no formato brasileiro com a '/' barra separando dia, mês e ano. * Portanto, caso a data seja informada dessa forma substituir a '/' barra pelo '-' hifém */ if (strpos($data_hora, '/') > -1) { $data_hora = str_replace('/', '-', $data_hora); } // Fim if return date_format(date_create($data_hora), $formato); } // Fim if }
public function check_due_date($date) { echo $date; $query = $this->db->query('SELECT * FROM rent_details')->result_array(); //exit(); foreach ($query as $key) { $due_date = $key['rent_due_date']; $rent = $key['rent']; $id = $key['id']; $rent_balance = $key['rent_balance']; $new_rent_balance = $rent_balance + $rent; $new_date = date_create($due_date); date_add($new_date, date_interval_create_from_date_string("30 days")); $new_rent_due_date = date_format($new_date, "Y-m-d"); echo $new_rent_due_date; $date1 = date_create($date); $date2 = date_create($due_date); $diff = date_diff($date1, $date2); $dif = $diff->format("%a"); if ($dif == 0) { if ($new_rent_balance <= 0) { $this->db->query("UPDATE rent_details SET rent_due = '0' WHERE id ='" . $id . "'"); # code... } else { $this->db->query("UPDATE rent_details SET rent_due = '" . $new_rent_balance . "' WHERE id ='" . $id . "'"); } $this->db->query("UPDATE rent_details SET rent_balance = '" . $new_rent_balance . "' WHERE id ='" . $id . "'"); $this->db->query("UPDATE rent_details SET rent_due_date = '" . $new_rent_due_date . "' WHERE id ='" . $id . "'"); } else { //$this->db->query('UPDATE rent_details SET rent_due = '0''); } } }
private function setTimeFrame() { if ($this->Input->post('all')) { $this->Template->fromDate = date("d.m.Y", mktime(0, 0, 0, 5, 1, 2014)); $this->Template->toDate = date("d.m.Y", mktime(0, 0, 0, 7, 31, 2014)); } else { if ($this->Input->post('past')) { $this->Template->fromDate = date("d.m.Y", strtotime($this->Template->fromDate) - $this->past_days); $this->Template->toDate = date("d.m.Y", strtotime($this->Template->toDate) - $this->future_days); } else { if ($this->Input->post('future')) { $this->Template->fromDate = date("d.m.Y", strtotime($this->Template->fromDate) + $this->past_days); $this->Template->toDate = date("d.m.Y", strtotime($this->Template->toDate) + $this->future_days); } else { $this->Template->fromDate = date("d.m.Y", mktime(0, 0, 0, date("m"), date("d") - $this->past_days, date("Y"))); $this->Template->toDate = date("d.m.Y", mktime(0, 0, 0, date("m"), date("d") + $this->future_days, date("Y"))); } } } if ($this->Input->post('fromDate')) { $this->Template->fromDate = date_format(date_create($this->Input->post('fromDate')), 'd.m.Y'); } if ($this->Input->post('toDate')) { $this->Template->toDate = date_format(date_create($this->Input->post('toDate')), 'd.m.Y'); } }
protected function loadQuotes() { if ($this->code === null) { throw new \BadMethodCallException('Initialize code'); } if ($this->count === null) { throw new \BadMethodCallException('Initialize count'); } if ($this->quotes === null) { $client = new YahooFinanceClient(); $start = date_create()->modify('-1 month'); $end = date_create(); $this->quotes = []; foreach (range(0, 23) as $month) { try { $data = $client->getHistoricalData($this->code, $start, $end); $this->quotes[] = $data['query']['results']['quote'][0]; } catch (ApiException $e) { // TODO should be logged? Throws an exception if earlier than certain date break; } $start->modify('-1 month'); $end->modify('-1 month'); } } return $this->quotes; }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $dados = $request->all(); $date = date_create($dados["data"]); $dados["data"] = date_format($date, "Y-m-d H:i"); return \DB::connection('mysql')->table('feira')->where('id', $id)->update(['tipo' => $dados['tipo'], 'tema' => $dados['tema'], 'local' => $dados['local'], 'data' => $dados['data'], 'status' => $dados['status'], 'observacao' => $dados['observacao']]); }
public function weekday($date) { $CI =& get_instance(); $time = date_create($date); $weekday_num = date_format($time, 'N'); switch ($weekday_num) { case '1': $weekday = 'пн'; break 1; case '2': $weekday = 'вт'; break 1; case '3': $weekday = 'ср'; break 1; case '4': $weekday = 'чт'; break 1; case '5': $weekday = 'пт'; break 1; case '6': $weekday = 'сб'; break 1; case '7': $weekday = 'вс'; break 1; } return $weekday; }
public function storeTodo() { $app = $this->app; $title = $app->request->post('title'); $tododate = $app->request->post('tododate'); $todotime = $app->request->post('todotime'); if ($todotime == "") { $todotime = "00:00:00"; } $tododatetime_str = str_replace('/', '-', $tododate) . " " . $todotime; $tododatetime = date_create($tododatetime_str); $priority_id = $app->request->post('priority'); $priority = $this->getPriorityById($priority_id); $creationdate_str = date('Y-m-d H:i:s'); $creationdate = date_create($creationdate_str); $todo = new Todo(); $todo->setCreationdate($creationdate); $todo->setTitle($title); if ($tododate != "") { $todo->setTododate($tododatetime); } $todo->setPriority($priority); $em = $this->em; $em->persist($todo); $em->flush(); $app->flash("info", "'" . $todo . "' is added"); }
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 }
/** * End Date * * Returns the event end date * * @param int $event (optional) * @param bool $displayTime If true shows date and time, if false only shows date * @param string $dateFormat Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php) * @return string Date * @since 2.0 */ function tribe_get_end_date($event = null, $displayTime = true, $dateFormat = '') { if (is_null($event)) { global $post; $event = $post; } if (is_numeric($event)) { $event = get_post($event); } if (tribe_event_is_all_day($event)) { $displayTime = false; } if (empty($event->EventEndDate) && is_object($event)) { $event->EventEndDate = tribe_get_event_meta($event->ID, '_EventEndDate', true); } if (isset($event->EventEndDate)) { if (tribe_event_is_all_day($event) && empty($event->_end_date_fixed) && TribeDateUtils::timeOnly($event->EventEndDate) != '23:59:59' && TribeDateUtils::timeOnly(tribe_event_end_of_day()) != '23:59') { // set the event end date to be one day earlier, if it's an all day event and the cutoff is past midnight // @todo remove this once we can have all day events without a start / end time $event->EventEndDate = date_create($event->EventEndDate); $event->EventEndDate->modify('-1 day'); $event->EventEndDate = $event->EventEndDate->format(TribeDateUtils::DBDATEFORMAT); $event->_end_date_fixed = true; } $date = strtotime($event->EventEndDate); } else { return; // '—'; } return tribe_event_format_date($date, $displayTime, $dateFormat); }