本文整理汇总了PHP中Carbon::createFromFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::createFromFormat方法的具体用法?PHP Carbon::createFromFormat怎么用?PHP Carbon::createFromFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon
的用法示例。
在下文中一共展示了Carbon::createFromFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update($id)
{
$oss = Oss::find($id);
$oss->tanggal_oss = Carbon::createFromFormat('d/m/Y', Input::get('tanggal_oss'));
$oss->no_oss = Input::get('no_oss');
$oss->mitra_oss = Input::get('mitra_oss');
if (Input::get('nama_bantek') != '') {
$oss->nama_bantek_oss = Input::get('nama_bantek');
}
$oss->id_site = Input::get('id_site');
$oss->nama_site = Input::get('nama_site');
if (Input::get('tanggal_mulai') != '') {
$oss->tanggal_mulai_oss = Carbon::createFromFormat('d/m/Y', Input::get('tanggal_mulai'));
}
if (Input::get('tanggal_selesai') != '') {
$oss->tanggal_selesai_oss = Carbon::createFromFormat('d/m/Y', Input::get('tanggal_selesai'));
}
$oss->permasalahan_oss = Input::get('masalah');
$oss->action_oss = Input::get('action');
if (Input::get('rincian') != '') {
$oss->rincian_jasa_material_oss = Input::get('rincian');
}
if (Input::get('shopping_list') != '') {
$oss->kode_shopping_list = Input::get('shopping_list');
}
$oss->harga_oss = Input::get('harga');
$oss->req_oleh = Input::get('request');
$oss->diketahui_oleh = Input::get('approval');
$oss->save();
Session::flash('success', 'Data has been saved');
return Redirect::to('/oss');
}
示例2: getIncompleteProductLoads
public function getIncompleteProductLoads($user_id)
{
//get user and in progress product requests / ideas
$user = $this->eloquent->with(['ideas' => function ($query) {
$query->where('is_fulfilled', '=', 0);
}])->with(['productRequests' => function ($query) {
$query->whereNull('product_id');
}])->find($user_id);
if (empty($user)) {
return [];
}
$user = $user->toArray();
$product_requests = $user['product_requests'];
$ideas = $user['ideas'];
//compile inprogress items
$inprogress_items = new \Collection();
foreach ($product_requests as $product_request) {
$inprogress_items->add(['type' => 'id load', 'human_time_diff' => \Carbon::createFromFormat('Y-m-d H:i:s', $product_request['created_at'])->diffForHumans(), 'created_at' => $product_request['created_at'], 'updated_at' => $product_request['updated_at'], 'id' => $product_request['id'], 'description' => $product_request['vendor'] . ' ' . $product_request['vendor_id'], 'query' => ['vendor' => $product_request['vendor'], 'vendor_id' => $product_request['vendor_id']]]);
}
foreach ($ideas as $idea) {
$inprogress_items->add(['type' => 'idea load', 'human_time_diff' => \Carbon::createFromFormat('Y-m-d H:i:s', $idea['created_at'])->diffForHumans(), 'created_at' => $idea['created_at'], 'updated_at' => $idea['updated_at'], 'id' => $idea['id'], 'description' => $idea['description'], 'query' => ['idea_description' => $idea['description']]]);
}
$inprogress_items->sortBy('created_at');
return $inprogress_items->toArray();
}
示例3: saveFlights
/**
* @param $configdepart
* @return bool
*/
private function saveFlights(Configdepart $configdepart)
{
// Combien de flights à créer
$nbFlights = ceil($configdepart->nbjoueurs / $configdepart->slotbyflight) + $configdepart->startergap;
// Met a jour Configdepart->slotcount : nombre de places disponibes créees
$configdepart->slotcount = $nbFlights * $configdepart->slotbyflight;
$configdepart->save();
// Supprimer les Flight de cette config
$configdepart->flights()->delete();
// Boucle tous les flight à créer
for ($i = 1; $i <= $nbFlights; $i++) {
$addMinutes = ($i - 1) * $configdepart->interval;
$newheure = Carbon::createFromFormat('H:i', $configdepart->startheure)->addMinutes($addMinutes);
// New Flight
$flight = new Flight();
$flight->configdepart_id = $configdepart->id;
$flight->num = $i;
$flight->heure = $newheure;
$flight->save();
// Cree les slots
for ($slotnum = 1; $slotnum <= $configdepart->slotbyflight; $slotnum++) {
$slot = new Slot();
$slot->flight_id = $flight->id;
$slot->num = $slotnum;
$slot->entree_id = 0;
$slot->save();
}
}
return true;
}
示例4: __parseXMLDocument
protected function __parseXMLDocument()
{
$xml = new SimpleXMLElement($this->xmlDocument);
$this->date = Carbon::createFromFormat('Y-m-d', (string) $xml->Body->Cube['date']);
foreach ($xml->Body->Cube->Rate as $line) {
$this->currency[] = array("name" => $line["currency"], "value" => $line, "multiplier" => $line["multiplier"]);
}
}
示例5: getList
/**
* показываем список транзакций за указанную дату для текущего пользователя
*
* @return \Illuminate\Http\Response
*/
public function getList($date = '')
{
$date = $date ?: date("Y-m-d");
$start = \Carbon::createFromFormat("Y-m-d", $date)->startOfDay()->toDateTimeString();
$end = \Carbon::createFromFormat("Y-m-d", $date)->endOfDay()->toDateTimeString();
//
return ['content' => Transaction::with('card')->where('user_id', $this->user->id)->where('created_at', '>=', $start)->where('created_at', '<=', $end)->orderBy('created_at', 'DESC')->get()];
}
示例6: getEdad
public function getEdad()
{
try {
$cb_date = Carbon::createFromFormat('d/m/Y', Input::get('fecha_nacimiento'));
return Response::json(['edad' => $cb_date->age]);
} catch (InvalidArgumentException $e) {
return Response::json(['edad' => '']);
}
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$s3 = AWS::get('s3');
$s3Bucket = 'buildbrighton-bbms';
if (Request::hasFile('image')) {
$file = Request::file('image');
$event = Request::get('textevent');
$time = Request::get('time');
$fileData = Image::make($file)->encode('jpg', 80);
$date = Carbon::createFromFormat('YmdHis', $event);
$folderName = $date->hour . ':' . $date->minute . ':' . $date->second;
try {
$newFilename = \App::environment() . '/cctv/' . $date->year . '/' . $date->month . '/' . $date->day . '/' . $folderName . '/' . $time . '.jpg';
$s3->putObject(array('Bucket' => $s3Bucket, 'Key' => $newFilename, 'Body' => $fileData, 'ACL' => 'public-read', 'ContentType' => 'image/jpg', 'ServerSideEncryption' => 'AES256'));
} catch (\Exception $e) {
\Log::exception($e);
}
//Log::debug('Image saved :https://s3-eu-west-1.amazonaws.com/buildbrighton-bbms/'.$newFilename);
}
if (Request::get('eventend') == 'true') {
$event = Request::get('textevent');
$date = Carbon::createFromFormat('YmdHis', $event);
$folderName = $date->hour . ':' . $date->minute . ':' . $date->second;
$iterator = $s3->getIterator('ListObjects', array('Bucket' => $s3Bucket, 'Prefix' => \App::environment() . '/cctv/' . $date->year . '/' . $date->month . '/' . $date->day . '/' . $folderName));
$images = [];
$imageDurations = [];
foreach ($iterator as $object) {
$images[] = 'https://s3-eu-west-1.amazonaws.com/buildbrighton-bbms/' . $object['Key'];
$imageDurations[] = 35;
}
if (count($images) <= 2) {
//only two images, probably two bad frames
//delete them
foreach ($iterator as $object) {
Log::debug("Deleting small event image " . $object['Key']);
$s3->deleteObject(['Bucket' => $s3Bucket, 'Key' => $object['Key']]);
}
return;
}
$gc = new GifCreator();
$gc->create($images, $imageDurations, 0);
$gifBinary = $gc->getGif();
//Delete the individual frames now we have the gif
foreach ($iterator as $object) {
//Log::debug("Processed gif, deleting frame, ".$object['Key']);
$s3->deleteObject(['Bucket' => $s3Bucket, 'Key' => $object['Key']]);
}
//Save the gif
$newFilename = \App::environment() . '/cctv/' . $date->year . '/' . $date->month . '/' . $date->day . '/' . $folderName . '.gif';
$s3->putObject(array('Bucket' => $s3Bucket, 'Key' => $newFilename, 'Body' => $gifBinary, 'ACL' => 'public-read', 'ContentType' => 'image/gif', 'ServerSideEncryption' => 'AES256'));
//Log::debug('Event Gif generated :https://s3-eu-west-1.amazonaws.com/buildbrighton-bbms/'.$newFilename);
\Slack::to("#cctv")->attach(['image_url' => 'https://s3-eu-west-1.amazonaws.com/buildbrighton-bbms/' . $newFilename, 'color' => 'warning'])->send('Movement detected');
}
}
示例8: is_date_btw
function is_date_btw($key, $start_date, $end_date)
{
$key = Carbon::createFromFormat('Y-m-d', $key);
$start_date = Carbon::createFromFormat('Y-m-d', $start_date);
$end_date = Carbon::createFromFormat('Y-m-d', $end_date);
if ($key->gte($start_date) && $key->lte($end_date)) {
return true;
} else {
return false;
}
}
示例9: delocalize
public static function delocalize($date)
{
if (!isset($date) or gettype($date) == 'object') {
return $date;
} else {
if ($date == "") {
return null;
}
}
return Carbon::createFromFormat(trans('date.formats.default'), $date);
}
示例10: getMutatedValues
/**
* @return array Mutates the filter values so that it is readily prepared for processing.
*/
public function getMutatedValues()
{
$operator = head($this->values);
$dates = explode(' - ', last($this->values));
switch ($operator) {
case 'before':
return [DateRange::before(Carbon::createFromFormat(Filterable::$date_format, head($dates), 'GB')->startOfDay())];
case 'in':
return [new DateRange(Carbon::createFromFormat(Filterable::$date_format, head($dates), 'GB')->subDay()->endOfDay(), Carbon::createFromFormat(Filterable::$date_format, last($dates), 'GB')->addDay()->startOfDay())];
case 'not_in':
return [new DateRange(Carbon::createFromFormat(Filterable::$date_format, last($dates), 'GB')->addDay()->startOfDay(), Carbon::createFromFormat(Filterable::$date_format, head($dates), 'GB')->subDay()->endOfDay())];
case 'after':
return [DateRange::after(Carbon::createFromFormat(Filterable::$date_format, last($dates), 'GB')->endOfDay())];
}
}
示例11: update
public function update($id)
{
$fpl = Fpl::find($id);
$fpl->nama_pemohon = Input::get('nama_pemohon');
$fpl->tanggal_permintaan = Carbon::createFromFormat('d/m/Y', Input::get('tanggal_permintaan'));
$fpl->jenis_permintaan = Input::get('jenis_permintaan');
$fpl->perbaikan_pemeliharaan = Input::get('perbaikan');
$fpl->pembelian = Input::get('pembelian');
$fpl->alasan_kebutuhan = Input::get('alasan');
$fpl->jumlah_estimasi_harga = Input::get('estimasi');
$fpl->waktu_pengadaan = Carbon::createFromFormat('d/m/Y', Input::get('waktu_pengadaan'));
$fpl->trx_id = Input::get('trxid');
$fpl->no_acc = Input::get('acc');
$fpl->save();
Session::flash('success', 'Data has been updated');
return Redirect::to('/fpl');
}
示例12: parseFilter
public function parseFilter($campo, $valor, $query)
{
//se verifica si hay que buscar en otras tablas
if (str_contains($campo, '->')) {
$arrayOps = explode('->', $campo);
//relacion sencilla
if (count($arrayOps) == 2) {
$tabla = str_plural_spanish(explode('.', $arrayOps[0])[1]);
$campo = $tabla . '.' . $arrayOps[1];
} else {
if (count($arrayOps) == 3) {
$tabla = str_plural_spanish($arrayOps[1]);
$campo = $tabla . '.' . $arrayOps[2];
}
}
}
//arrays aplica whereIn, integer aplica =, strings aplica like %..%, fechas aplica >= o <= y se convierten en carbon
try {
$fecha = \Carbon::createFromFormat('d/m/Y', $valor);
$esfecha = true;
} catch (\Exception $e) {
$esfecha = false;
}
if ($esfecha) {
$operador = str_contains($campo, '_desde') ? '>=' : '<=';
$campo = str_replace('_desde', '', $campo);
$campo = str_replace('_hasta', '', $campo);
$query->where($campo, $operador, $fecha);
} else {
if (is_array($valor)) {
$query->whereIn($campo, $valor);
} else {
if (is_numeric($valor)) {
$query->where($campo, $valor);
} else {
if (is_string($valor)) {
//Se usa i like para que sea insensible a mayusculas
$query->where($campo, 'ILIKE', '%' . $valor . '%');
}
}
}
}
return $query;
}
示例13: setEditableInput
public function setEditableInput($key, $value)
{
if (isset(Config::get('users::settings_editable')[$key])) {
$type = Config::get('users::settings_editable')[$key];
if ($type == "date") {
$value = \Carbon::createFromFormat('Y/m/d H:i', $value);
} else {
if ($type == "bool") {
$value = (bool) $value;
} else {
if ($type == "number") {
$value = (int) $value;
}
}
}
$this->{$key} = $value;
}
return $this;
}
示例14: set_data
private function set_data($route)
{
$this->type = $route->type;
$this->id = $route->id;
$this->sourceId = $route->source;
$this->destinationId = $route->destination;
$this->productId = $route->product;
$product = $this->ci->routes_model->product($route->product);
$this->product = $product->productName;
$source = $this->ci->routes_model->city($route->source);
$this->source = $source->cityName;
$destination = $this->ci->routes_model->city($route->destination);
$this->destination = $destination->cityName;
$this->ci->db->order_by('id', 'desc');
$this->ci->db->where(array('route_id' => $route->id));
$this->ci->db->limit(1);
$freights = $this->ci->db->get('freights')->result();
//var_dump($freights);
if ($freights) {
$freight = $freights[0];
$this->freight = $freight->freight;
$this->startDate = $freight->startDate;
$this->endDate = $freight->endDate;
/*---checking is freight active----*/
$start = Carbon::createFromFormat('Y-m-d', $freight->startDate);
$end = Carbon::createFromFormat('Y-m-d', $freight->endDate);
$now = Carbon::createFromFormat('Y-m-d', date('Y-m-d'));
$this->is_freight_active = $now->between($start, $end);
$this->freight_id = $freight != null ? $freight->id : null;
$this->formatted_startDate = $freight != null ? $this->ci->carbon->createFromFormat('Y-m-d', $freight->startDate)->toFormattedDateString() : null;
$this->formatted_endDate = $freight != null ? $this->ci->carbon->createFromFormat('Y-m-d', $freight->endDate)->toFormattedDateString() : null;
} else {
$this->freight = null;
$this->startDate = null;
$this->endDate = null;
$this->formatted_endDate = null;
$this->formatted_startDate = null;
$this->freight_id = null;
}
}
示例15: formatMetrics
public function formatMetrics()
{
// get currently calculated metrics
$currentMetrics = Calculator::currentMetrics();
$this->date = Carbon::createFromFormat('Y-m-d', $this->date)->format('Y-m-d, l');
// go through them
foreach ($currentMetrics as $statID => $statName) {
if (is_null($this->{$statID})) {
$this->{$statID} = 'Not enough data';
} else {
switch ($statID) {
// money formats fall through
case 'mrr':
case 'arr':
case 'arpu':
// divide the value by 100
$this->{$statID} /= 100;
// format it into money
setlocale(LC_MONETARY, 'en_US');
$this->{$statID} = money_format('%n', $this->{$statID});
break;
// percent formats fall through
// percent formats fall through
case 'uc':
$this->{$statID} = $this->{$statID} . '%';
break;
// pieces formats fall through
// pieces formats fall through
case 'cancellations':
case 'au':
break;
default:
break;
}
// /switch
}
// /if
}
// /foreach
}