当前位置: 首页>>代码示例>>PHP>>正文


PHP date_create_from_format函数代码示例

本文整理汇总了PHP中date_create_from_format函数的典型用法代码示例。如果您正苦于以下问题:PHP date_create_from_format函数的具体用法?PHP date_create_from_format怎么用?PHP date_create_from_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了date_create_from_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: solicitar

 public function solicitar(Request $request)
 {
     $inputs = \Input::all();
     //        dd($request->all());
     try {
         //            $this->_validador->validate($inputs);
         $registro = new Solicitudes();
         $fecha = date_create_from_format('j.m.Y h:i a', $request->get('fecha'));
         $fecha = $fecha->format('Y-m-j H:i:s');
         $registro->cliente = Auth::user()->id;
         $registro->especificaciones = $request->get('mensaje');
         $registro->fechayhora = $fecha;
         $registro->estado = 0;
         $registro->save();
         foreach ($request->get('servicios') as $servicio => $sid) {
             $ser = new Serviciossolicitados();
             $ser->solicitud = $registro->id;
             $ser->servicio = $sid;
             $ser->save();
         }
         dd('yeh');
         return \Redirect::route('publicCuenta')->with('alerta', 'Tu reservacion!');
     } catch (ValidationException $e) {
         return \Redirect::route('publicReservacion')->withInput()->withErrors($e->get_errors());
     }
 }
开发者ID:JFSolorzano,项目名称:Acordes,代码行数:26,代码来源:ServiciosCtrl.php

示例2: isValid

 /**
  * Returns TRUE if submitted value validates according to rule
  *
  * @return boolean
  * @see \TYPO3\CMS\Form\Validation\ValidatorInterface::isValid()
  */
 public function isValid()
 {
     if ($this->requestHandler->has($this->fieldName)) {
         $value = $this->requestHandler->getByMethod($this->fieldName);
         if (function_exists('strptime')) {
             $parsedDate = strptime($value, $this->format);
             $parsedDateYear = $parsedDate['tm_year'] + 1900;
             $parsedDateMonth = $parsedDate['tm_mon'] + 1;
             $parsedDateDay = $parsedDate['tm_mday'];
             return checkdate($parsedDateMonth, $parsedDateDay, $parsedDateYear);
         } else {
             // %a => D : An abbreviated textual representation of the day (conversion works only for english)
             // %A => l : A full textual representation of the day (conversion works only for english)
             // %d => d : Day of the month, 2 digits with leading zeros
             // %e => j : Day of the month, 2 digits without leading zeros
             // %j => z : Day of the year, 3 digits with leading zeros
             // %b => M : Abbreviated month name, based on the locale (conversion works only for english)
             // %B => F : Full month name, based on the locale (conversion works only for english)
             // %h => M : Abbreviated month name, based on the locale (an alias of %b) (conversion works only for english)
             // %m => m : Two digit representation of the month
             // %y => y : Two digit representation of the year
             // %Y => Y : Four digit representation for the year
             $dateTimeFormat = str_replace(array('%a', '%A', '%d', '%e', '%j', '%b', '%B', '%h', '%m', '%y', '%Y'), array('D', 'l', 'd', 'j', 'z', 'M', 'F', 'M', 'm', 'y', 'Y'), $this->format);
             $dateTimeObject = date_create_from_format($dateTimeFormat, $value);
             if ($dateTimeObject === FALSE) {
                 return FALSE;
             }
             return $value === $dateTimeObject->format($dateTimeFormat);
         }
     }
     return TRUE;
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:38,代码来源:DateValidator.php

示例3: timeDiff

 /**
  * This calculates time difference in seconds between now and given timestamp
  *
  * @param string $ts
  * @param string $format
  * @return int
  */
 public static function timeDiff($ts, $format = 'Ymd-H:i:s')
 {
     $date = date_create_from_format($format, $ts);
     $now = new DateTime();
     $diff = $date->diff($now);
     return abs($diff->days * 24 * 60 * 60 + $diff->h * 60 * 60 + $diff->i * 60 + $diff->s);
 }
开发者ID:travijuu,项目名称:bkm-express,代码行数:14,代码来源:Calculate.php

示例4: addkillAction

 public function addkillAction()
 {
     $npc = $this->params()->fromPost('npc');
     $killtime = $this->params()->fromPost("killtime");
     if ($npc && $killtime) {
         $date = date_create_from_format("D M d H:i:s Y", $killtime);
         $npcName = rtrim($npc, "'\r");
         $npcMapper = $this->getServiceLocator()->get("DB\\Mapper\\NPC");
         $killMapper = $this->getServiceLocator()->get("DB\\Mapper\\Kill");
         $npc = $npcMapper->findByName($npcName);
         if ($npc) {
             if ($npc->getKill() && $npc->getKill()->getCrDate() >= $date) {
                 return new JsonModel(['statusMessage' => sprintf("Old Kill from NPC '%s'", $npcName), 'statusCode' => 1]);
             }
             $killMapper->cleanNPC($npc);
             $kill = new \DB\Entity\Kill();
             $kill->setCrDate($date);
             $spawnTime = clone $date;
             $spawnTime->add(new \DateInterval("PT" . $npc->getSpawnInterval() . "M"));
             $kill->setSpawnTime($spawnTime);
             $kill->setNpc($npc);
             $kill->setSpawnInterval($npc->getSpawnWindow());
             $npc->setKill($kill);
             $npcMapper->update($kill);
             // Add to Kill Log
             $killLog = new \DB\Entity\KillLog();
             $killLog->setCrDate($date);
             $killLog->setNpc($npc);
             $npcMapper->insert($killLog);
             return new JsonModel(['statusMessage' => sprintf("Kill of '%s' successful added", $npcName), 'statusCode' => 0]);
         }
         return new JsonModel(['statusMessage' => sprintf("NPC with name '%s' not found", $npcName), 'statusCode' => 2]);
     }
     return new JsonModel(['statusMessage' => 'Error', 'statusCode' => 3]);
 }
开发者ID:kempfe,项目名称:eqtracker,代码行数:35,代码来源:ParserController.php

示例5: guardarProforma

 /**
  * @param $data
  * @return int|string
  */
 public function guardarProforma($data, $archivo)
 {
     $result = "0";
     try {
         //            var_dump($data);
         $date = date_create_from_format('d/m/Y', $data["fecha"]);
         //            var_dump($date);
         $proforma = new Proformas();
         $proforma->setAlmacen($data["almacen"]);
         $proforma->setIdAlmacen($data["idalmacen"]);
         $proforma->setIdMarca($data["idmarca"]);
         $proforma->setNombreArchivo($archivo["nombre_archivo"]);
         $proforma->setTipoArchivo($archivo["tipo_archivo"]);
         $proforma->setUrlArchivo($archivo["url_archivo"]);
         $proforma->setMarca($data["marca"]);
         $proforma->setEstado("NUEVO");
         $proforma->setNombre($data["nombre"]);
         $proforma->setNroFactura($data["nro_factura"]);
         $proforma->setFecha($date);
         //        $proforma->set
         $this->_em->persist($proforma);
         $this->_em->flush();
         $result = $proforma->getIdProforma();
     } catch (\Exception $e) {
         //            var_dump($e);
         $result = $e->getMessage();
     }
     return $result;
 }
开发者ID:uvillazon,项目名称:NovamodaMayor,代码行数:33,代码来源:ProformasRepository.php

示例6: date_to_time

function date_to_time($date, $format = "Y-m-d H:i:s")
{
    if (!$date) {
        return;
    }
    return @date_format(date_create_from_format($format, $date), 'U');
}
开发者ID:alexandre-le-borgne,项目名称:-PHP-DUT-S3-Projet,代码行数:7,代码来源:date_to_time.php

示例7: reportUmurBarang

 public function reportUmurBarang()
 {
     $dari = date_format(date_create_from_format('d-m-Y', $this->dari), 'Y-m-d');
     $sampai = date_format(date_create_from_format('d-m-Y', $this->sampai), 'Y-m-d');
     if (empty($this->bulan)) {
         $whereBulan = "inventory_balance.created_at BETWEEN :dari AND :sampai";
     } else {
         $whereBulan = "TIMESTAMPDIFF(MONTH, inventory_balance.created_at, NOW()) >= :bulan";
     }
     $kategoriQuery = '';
     if (!empty($this->kategoriId)) {
         $kategoriQuery = 'JOIN barang ON inventory_balance.barang_id = barang.id
                             AND barang.kategori_id = :kategoriId';
     }
     $command = Yii::app()->db->createCommand();
     $command->select("\n                t_inventory.*,\n                SUM(ib.qty) total_stok,\n                TIMESTAMPDIFF(MONTH, tgl_beli_awal, NOW()) umur_bulan,\n                TIMESTAMPDIFF(DAY, tgl_beli_awal, NOW()) umur_hari,\n                barang.barcode,\n                barang.nama\n                ");
     $command->from("\n                (SELECT \n                    barang_id,\n                        SUM(qty) qty,\n                        SUM(qty * harga_beli) nominal,\n                        MIN(inventory_balance.created_at) tgl_beli_awal,\n                        COUNT(*) count\n                FROM\n                    inventory_balance\n        {$kategoriQuery}    \n                WHERE\n        {$whereBulan}\n                        AND qty > 0\n                GROUP BY barang_id\n                LIMIT {$this->limit}) AS t_inventory\n                ");
     $command->join('inventory_balance ib', 't_inventory.barang_id = ib.barang_id');
     $command->join('barang', 't_inventory.barang_id = barang.id');
     $command->group('barang_id');
     $command->order([$this->listSortBy2()[$this->sortBy0], $this->listSortBy2()[$this->sortBy1]]);
     if (!empty($this->kategoriId)) {
         $command->bindValue(':kategoriId', $this->kategoriId);
     }
     if (empty($this->bulan)) {
         $command->bindValue(':dari', $dari);
         $command->bindValue(':sampai', $sampai);
     } else {
         $command->bindValue(':bulan', $this->opsiUmurBulan2()[$this->bulan]);
     }
     return $command->queryAll();
 }
开发者ID:AbuMuhammad,项目名称:ap3,代码行数:32,代码来源:ReportUmurBarangForm.php

示例8: get_user_old_ldap

 function get_user_old_ldap($email)
 {
     $attributes = ["uid" => "uid", "mail" => "mail", "givenName" => "firstname", "sn" => "lastname", "displayName" => "nick", "gender" => "gender", "birthdate" => "dob", "o" => "organization", "c" => "country", "l" => "location"];
     $this->load_library("ldap_lib", "ldap");
     $ds = $this->ldap->get_link();
     $dn = "dc=felicity,dc=iiit,dc=ac,dc=in";
     $filter = '(&(mail=' . $email . '))';
     $sr = ldap_search($ds, $dn, $filter, array_keys($attributes));
     $entry = ldap_first_entry($ds, $sr);
     if (!$entry) {
         return false;
     }
     $entry_data = ldap_get_attributes($ds, $entry);
     $user_data = [];
     foreach ($attributes as $key => $value) {
         if (isset($entry_data[$key]) && isset($entry_data[$key][0])) {
             $user_data[$value] = $entry_data[$key][0];
         }
     }
     if (isset($user_data["dob"])) {
         $date = date_create_from_format('d/m/Y', $user_data["dob"]);
         if ($date) {
             $user_data["dob"] = date_format($date, "Y-m-d");
         }
     }
     if (isset($user_data["firstname"]) && isset($user_data["lastname"])) {
         $user_data["name"] = implode(" ", [$user_data["firstname"], $user_data["lastname"]]);
         unset($user_data["firstname"]);
         unset($user_data["lastname"]);
     }
     if (isset($user_data["gender"])) {
         $user_data["gender"] = strtolower($user_data["gender"]);
     }
     return $user_data;
 }
开发者ID:hharchani,项目名称:felicity16-website,代码行数:35,代码来源:auth_model.php

示例9: postDiscount

 public function postDiscount()
 {
     $id = \Input::get('id');
     $rules = array('pricelist_id' => 'required', 'code' => 'required', 'expiry_date' => 'required', 'percent' => 'required|numeric|min:1|max:100');
     $validation = \Validator::make(\Input::all(), $rules);
     if ($validation->passes()) {
         $pricelist_id = \Input::get('pricelist_id');
         $code = \Input::get('code');
         $expiry_date = \Input::get('expiry_date');
         $percent = \Input::get('percent');
         $pricelist = Pricelist::find($pricelist_id);
         // No such id
         if ($pricelist == null) {
             $errors = new \Illuminate\Support\MessageBag();
             $errors->add('deleteError', "The pricelist for discount may have been deleted. Please try again.");
             return \Redirect::to('admin/pricelists')->withErrors($errors)->withInput();
         }
         $newDiscount = new Discount();
         $newDiscount->code = $code;
         $newDiscount->expiry_date = date_create_from_format('d/m/Y H:i:s', $expiry_date . ' 00:00:00');
         $newDiscount->percent = $percent;
         $pricelist->discounts()->save($newDiscount);
     } else {
         return \Redirect::to('admin/pricelists')->withErrors($validation)->withInput();
     }
     return \Redirect::to('admin/pricelists');
 }
开发者ID:tusharvikky,项目名称:redminportal,代码行数:27,代码来源:PricelistController.php

示例10: formatValidate

 /**
  * Format validation for the value.
  *
  * @return int
  */
 protected function formatValidate()
 {
     if ($this->value && ($format = $this->getFormat()) && date_create_from_format($format, $this->value) === false) {
         return static::INVALID_CODE_FORMAT;
     }
     return static::VALID_CODE_SUCCESS;
 }
开发者ID:Top-Tech,项目名称:Top-tech,代码行数:12,代码来源:DatetimeInput.php

示例11: handleRequestData

 public function handleRequestData()
 {
     $data = Input::all();
     $customerData = new CustomerData();
     $customerData->firstname = $data['firstname'];
     $customerData->lastname = $data['lastname'];
     $customerData->email = $data['email'];
     $customerData->mobile = $data['mobile'];
     $customerData->description = $data['description'];
     if ($data['appointment']) {
         $appointment_dt = date_create_from_format('d F Y - H:i', $data['appointment']);
         $customerData->appointment = $appointment_dt;
     } else {
         $customerData->appointment = null;
     }
     $customerData->save();
     if ($customerData->appointment) {
         $customerData->appointment = $customerData->appointment->format('d F Y - H:i');
     } else {
         $customerData->appointment = '-';
     }
     $subject = (string) ('customer contact #' . $customerData->id);
     Mail::send('customers.email', array('data' => $customerData), function ($message) use($subject) {
         $message->to('Privatepark3@gmail.com', 'AUTHOR - PRIVATE CONTACT')->from('Privatepark3@gmail.com', 'PRIVATE PARK')->subject($subject);
     });
     return Redirect::to('/');
 }
开发者ID:kongbhop,项目名称:estateProject,代码行数:27,代码来源:CustomerController.php

示例12: getDayDiff

 public static function getDayDiff($input_date_l, $input_date_r)
 {
     $date_1 = date_create_from_format('Y-m-d', $input_date_l);
     $date_2 = date_create_from_format('Y-m-d', $input_date_r);
     $interval = date_diff($date_1, $date_2);
     return $interval->format('%a') + 1;
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:7,代码来源:DateTimeUtils.php

示例13: checkForNews

 private function checkForNews()
 {
     try {
         $response = (new Client())->createRequest()->setUrl($this->getCurrentFeed()->url)->send();
         if (!$response->isOk) {
             throw new \Exception();
         }
         $rss = simplexml_load_string($response->getContent());
         $newItemsCount = 0;
         foreach ($rss->channel->item as $item) {
             if (!NewModel::findOne(['feed' => $this->getCurrentFeed()->id, 'url' => (string) $item->link])) {
                 $new = new NewModel();
                 $new->feed = $this->getCurrentFeed()->id;
                 $new->published_at = date_create_from_format(\DateTime::RSS, (string) $item->pubDate)->format('Y-m-d H:i:s');
                 $new->title = (string) $item->title;
                 if (isset($item->description)) {
                     $new->short_text = StringHelper::truncate(strip_tags((string) $item->description), 250);
                 }
                 $new->url = (string) $item->link;
                 if ($new->save()) {
                     $newItemsCount++;
                 }
             }
         }
         if ($newItemsCount > 0) {
             \Yii::$app->session->addFlash('info', \Yii::t('user', 'Get news: ') . $newItemsCount);
             $this->clearOldNewsIfNeed();
             \Yii::$app->cache->delete($this->getNewsCacheKey());
             \Yii::$app->cache->delete($this->getFeedsCacheKey());
         }
     } catch (Exception $e) {
         \Yii::$app->session->addFlash('danger', \Yii::t('user', 'Get news error'));
     }
 }
开发者ID:atoumus,项目名称:yii2-rss-reader-example,代码行数:34,代码来源:ListAction.php

示例14: showresult

 public function showresult($date = '')
 {
     if (empty($date)) {
         $date = date_create('now');
     } else {
         $date = date_create_from_format('Y-m-d', $date);
     }
     $date->setTime(0, 0, 0);
     $today_date = date_create('now')->setTime(0, 0, 0);
     //block future date results
     if ($date > $today_date) {
         $datestr = $date->format('Y-m-d');
         $error = 'Future date, Result not declared yet';
         return view('results', compact('error', 'datestr'));
     }
     $datestr = $date->format('Y-m-d');
     $current_time = intval(date('Hi'));
     $_results = Result::with('lottery')->with('series')->where("date", '=', $date)->orderBy('lottery_id')->orderBy('series_id')->get();
     // dd($results[0]);
     $results = array();
     $time = date("");
     if (count($_results) > 0) {
         foreach ($_results as $_result) {
             if ($date == $today_date && intval($_result->lottery->draw_time) > $current_time) {
                 continue;
             }
             if (empty($results["{$_result->lottery->draw_time}"])) {
                 $results["{$_result->lottery->draw_time}"] = array();
             }
             $results["{$_result->lottery->draw_time}"]["{$_result->series->code}"] = $_result->winning_number;
         }
     }
     $series = Series::all();
     return view('results', compact('results', 'series', 'datestr'));
 }
开发者ID:gxrahul,项目名称:playgoldwin2,代码行数:35,代码来源:HomeController.php

示例15: postRegisterAction

 /**
  *
  * @param ParamFetcher $paramFetcher Paramfetcher
  *
  * @RequestParam(name="username", nullable=false, strict=true, description="Username")
  * @RequestParam(name="email", nullable=false, strict=true, description="Email")
  * @RequestParam(name="password", nullable=false, strict=true, description="password")
  * @RequestParam(name="birthday", nullable=false, strict=true, description="Birthday")
  * @RequestParam(name="brand", nullable=false, strict=true, description="Brand")
  * @RequestParam(name="sex", nullable=false, strict=true, description="Sex")
  *
  */
 public function postRegisterAction(ParamFetcher $paramFetcher)
 {
     $username = $paramFetcher->get('username');
     $email = $paramFetcher->get('email');
     $password = $paramFetcher->get('password');
     $birthday = date_create_from_format('j/m/Y', $paramFetcher->get('birthday'));
     $brand = $paramFetcher->get('brand');
     $brand = $this->getDoctrine()->getRepository('zenitthApiBundle:brands')->find($brand);
     $sex = $paramFetcher->get('sex');
     $userManager = $this->get('fos_user.user_manager');
     $user = $userManager->createUser();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setPlainPassword($password);
     $user->setEnabled(true);
     $user->setRoles(array('ROLE_APPLI'));
     $user->setBirthdate($birthday);
     $user->setUserBrand($brand);
     $user->setSexe($sex);
     $user->setScore(0);
     $apiKey = sha1($user->getSalt() . $user->getId());
     $user->setApiKey($apiKey);
     $userManager->updateUser($user);
     $clientManager = $this->container->get('fos_oauth_server.client_manager.default');
     $client = $clientManager->createClient();
     $client->setRedirectUris(array(''));
     $client->setAllowedGrantTypes(array('http://zenitth.com/grants/api_key', 'refresh_token'));
     $client->setUser($user);
     $clientManager->updateClient($client);
     $clientId = $client->getId() . "_" . $client->getRandomId();
     $secret = $client->getSecret();
     $key = $apiKey;
     return array('clientId' => $clientId, 'secretId' => $secret, 'key' => $key);
 }
开发者ID:Zenitth,项目名称:server-side,代码行数:46,代码来源:AccountController.php


注:本文中的date_create_from_format函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。