/** * @return array */ public function toArray() { $filters = []; $filters[] = ['name' => 'from_date', 'value' => $this->fromDate->toDateTimeString()]; $filters[] = ['name' => 'until_date', 'value' => $this->untilDate->toDateTimeString()]; return $filters; }
public function GetProfilePrices($id) { $date = new Carbon(); $date->subDays(4); $prices = DB::table('profile_history_prices')->where('created_at', '>', $date->toDateTimeString())->where('profile_id', $id)->get(['created_at', 'price']); $hashtag = $this->GetProfileById($id); if ($hashtag->created_at > $date) { array_unshift($prices, array('price' => 0, 'created_at' => $hashtag->created_at->toDateTimeString())); array_unshift($prices, array('price' => 0, 'created_at' => $date->toDateTimeString())); } return $prices; }
/** * @param Carbon $now * @param string $externalApiName * @param int $externalApiLimit * @param string $externalApiLimitInterval * * @return mixed */ public function addExternalAPILimitCounter(Carbon $now, $externalApiName = 'test', $externalApiLimit = 100000, $externalApiLimitInterval = 'Day') { $ExternalApiLimit = ExternalApiLimit::where('external_api_name', $externalApiName)->where('external_api_limit_interval', $externalApiLimitInterval)->where('limit_interval_start', '<=', $now->toDateTimeString())->where('limit_interval_end', '>=', $now->toDateTimeString())->first(); if (empty($ExternalApiLimit)) { $ExternalApiLimit = new ExternalApiLimit(); $ExternalApiLimit->external_api_name = $externalApiName; $ExternalApiLimit->external_api_limit_interval = $externalApiLimitInterval; $ExternalApiLimit->external_api_limit = $externalApiLimit; $StartEnd = ExternalApiLimit::convertIntervalStringToStartEnd($externalApiLimitInterval, $now); $ExternalApiLimit->limit_interval_start = $StartEnd['limit_interval_start']; $ExternalApiLimit->limit_interval_end = $StartEnd['limit_interval_end']; } $ExternalApiLimit->external_api_count = $ExternalApiLimit->external_api_count + 1; $ExternalApiLimit->save(); return $ExternalApiLimit->external_api_limit_left; }
/** * Scope a query to only contain battles that are closed for voting */ public function scopeCompleted($query) { $votingperiod = config('rap-battle.votingperiod', 24); // battles before this date are closed: $timeoldest = new Carbon(); $timeoldest->subHours($votingperiod); return $query->where('created_at', '<', $timeoldest->toDateTimeString()); }
/** * @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query */ protected function setupQuery($query) { if ($this->start) { $query->where('created_at', '>=', $this->start->toDateTimeString()); } if ($this->end) { $query->where('created_at', '<=', $this->end->toDateTimeString()); } }
/** * Release the job back into the queue. * * @param int $delay * @return void */ public function release($delay = 0) { $now = new Carbon(); $now->addSeconds($delay); $this->job->timestamp = $now->toDateTimeString(); $this->job->status = Job::STATUS_WAITING; $this->job->retries += 1; $this->job->save(); $this->released = true; }
function getTimelineAttribute() { $date = new Carbon(); $date->subDays(2); $today = Carbon::now(); // Assignments that need to be completed in 2 days $waiting_assignments = DB::table('assignments')->select(DB::raw('id, point, created_at, due_date as date, \'reminder\' as type'))->where('due_date', '>', $date->toDateTimeString())->where('due_date', '>=', $today->toDateTimeString())->whereNotExists(function ($query) { $query->select(DB::raw(1))->from('users_assignments')->whereRaw('users_assignments.assignment_id = assignments.id')->where('users_assignments.user_id', '=', $this->id); }); $timeline = DB::table('users_assignments')->select(DB::raw('assignment_id, point, null, created_at as date, \'assignment\' as type'))->where('user_id', '=', $this->id)->union($waiting_assignments)->orderBy('date', 'desc')->get(); return $timeline; }
public function store(Requests\PostStoreRequest $request) { $post = new Post(); $post->title = $request->title; $post->url = $request->url; $post->body = $request->body; if ($request->published_at != "") { $time = new Carbon($request->published_at); $post->published_at = $time->toDateTimeString(); } else { $post->published_at = null; } $post->save(); return redirect('/back/posts')->with('status', 'Created Post'); }
/** * Create a new Alert instance. * * @param string $msg * @param string $type * @param string $datetime * * @return void */ public function __construct($msg, $type, $datetime = null) { if (empty($msg) || empty($type)) { throw new Exception("Invalid Parameters"); } if (!$this->isValidType($type)) { throw new Exception("Invalid alert type"); } $this->id = uniqid(); $this->message = $msg; $this->type = $type; if (!is_null($datetime)) { $dt = new Carbon($datetime); $this->datetime = $dt->toDateTimeString(); } else { $this->datetime = null; } }
public function update(Request $request, $id) { $session_id = Session::getId(); if (!$session_id) { return response('', 400); } $this->validate($request, ['id' => 'required|integer']); $bookmark = Bookmark::find($id); if ($request->bookmark) { $bookmark->bookmark = $request->bookmark; $bookmark->save(); } if ($request->bookmarked_at) { $bookmarked_at = new Carbon($request->bookmarked_at, auth()->user()->timezone); $bookmarked_at->setTimezone('UTC'); $bookmark->bookmarked_at = $bookmarked_at->toDateTimeString(); $bookmark->save(); } return response('', 204); }
public function testRegister() { $birthday = new Carbon(); $birthday->addYear(-23); $this->visit('/auth/register')->type('user1', 'name')->type('*****@*****.**', 'email')->type('useruser', 'password')->type('useruser', 'password_confirmation')->type($birthday->toDateTimeString(), 'bdate')->select('1', 'gender')->type('2000', 'daily_calories'); $map = []; $restrictions = Restriction::all(); foreach ($restrictions as $restriction) { $val = round(mt_rand() / mt_getrandmax()); $map[$restriction->id] = $val; $this->type($val + 1, 'restriction' . ($restriction->id + 1)); } $this->press('Register')->seePageIs('/home'); $this->seeInDatabase('users', ['name' => 'user1', 'email' => '*****@*****.**', 'bdate' => $birthday->toDateString(), 'gender' => '0', 'daily_calories' => '2000']); $user = \App\User::whereEmail('*****@*****.**')->first(); foreach ($restrictions as $restriction) { if ($map[$restriction->id] == 1) { $this->seeInDatabase('restriction_user', ['user_id' => $user->id, 'restriction_id' => $restriction->id]); } } }
public function checkIsLimitOverByUser($action, $user, $isFail = null) { $config = $this->getActionConfig($action); if (!isset($config['by_user'])) { return; } $config = $config['by_user']; $userId = $user instanceof User ? $user->id : (int) $user; $query = DB::table('user_action_log')->select('id')->where('action', $action)->where('user_id', $userId); if (isset($config['interval'])) { $fromDate = new Carbon(); $fromDate->subMinutes($config['interval']); $query->where('action_date', '>=', $fromDate->toDateTimeString()); } if ($isFail !== null) { $isFail = $isFail === true ? BaseModel::TRUE : BaseModel::FALSE; $query->where('is_fail', $isFail); } $maxTriesCount = isset($config['requests_count']) ? $config['requests_count'] : 1; $tries = $query->orderBy('id', 'desc')->take($maxTriesCount + 1)->get(); if (count($tries) > $maxTriesCount) { throw new TooMuchRequestException(); } }
use CarbonExt\FiscalYear\Calculator; // Object Instantiation $brisbane = new Carbon('2015-12-01', 'Australia/Brisbane'); $newYorkCity = new Carbon('2015-12-01', 'America/New_York'); $dtBerlin = new Carbon('2015-12-01', 'Europe/Berlin'); $outputString = "Time difference between %s & %s: %s hours.\n"; // Date difference printf($outputString, "Berlin", "Brisbane, Australia", $dtBerlin->diffInHours($brisbane, false)); printf($outputString, "Berlin", "New York City, America", $dtBerlin->diffInHours($newYorkCity, false)); $septEighteen2014 = Carbon::createFromDate(2014, 9, 18, $dtBerlin->getTimezone()); printf("difference between now and %s in \n\thours: %d, \n\tdays: %d, \n\tweeks: %d, \n\tweekend days: %d, \n\tweek days: %s, \n\thuman readable: %s\n", $septEighteen2014->toFormattedDateString(), $dtBerlin->diffInHours($septEighteen2014), $dtBerlin->diffInDays($septEighteen2014), $dtBerlin->diffInWeeks($septEighteen2014), $dtBerlin->diffInWeekendDays($septEighteen2014), $dtBerlin->diffInWeekDays($septEighteen2014), $dtBerlin->diffForHumans($septEighteen2014)); // Date formatting echo $dtBerlin->toDateString() . "\n"; echo $dtBerlin->toFormattedDateString() . "\n"; echo $dtBerlin->toTimeString() . "\n"; echo $dtBerlin->toDateTimeString() . "\n"; echo $dtBerlin->toDayDateTimeString() . "\n"; echo $dtBerlin->toRfc1036String() . "\n"; echo $dtBerlin->toAtomString() . "\n"; echo $dtBerlin->toCookieString() . "\n"; echo $dtBerlin->toRssString() . "\n"; $dtBerlin->setToStringFormat('l jS \\of F Y'); echo $dtBerlin . "\n"; echo (int) $dtBerlin->isLeapYear() . "\n"; // is* range of functions test printf("Is yesterday? %s\n", $dtBerlin->isYesterday() ? "yes" : "no"); printf("Is a Thursday? %s\n", $dtBerlin->isThursday() ? "yes" : "no"); printf("Is in the future? %s\n", $dtBerlin->isFuture() ? "yes" : "no"); printf("Is a leap year? %s\n", $dtBerlin->isLeapYear() ? "yes" : "no"); // first and last of the month printf("First of the month %s\n", $dtBerlin->firstOfMonth());
public function getResultsBetween(Carbon $startTime, Carbon $endTime) { $className = get_class($this); /** @var myModel $this */ return $this->getModelsManager()->createBuilder()->from($className)->where('created_at > :start:', ['start' => $startTime->toDateTimeString()])->andWhere('created_at < :end:', ['end' => $endTime->toDateTimeString()])->orderBy('created_at DESC'); }
public function __toString() { return "サイト復活\n" . $this->time->toDateTimeString() . "\n" . $this->url . "\n"; }
/** * Method to parse each article entry from the XML feed and save all its data, taxonomy terms and custom fields * * @param $article * * @return int $articleCount The count of how many articles were parsed to be returned back to parseFeed */ protected function parseArticles($article) { // Start the articleCount variable $articleCount = 0; // Get all cpi: nodes from the XML $cpiNamespace = $article->children('cpi', true); // Get Article Entry ID from the URL in the id node // ID after the last slash / $article_id_url = explode('/', $article->id); $article_entry_id = trim(array_pop($article_id_url)); // Add try catch in order to show possible date format erros on CMS Log try { $article_entry_published = new Carbon($article->published); $article_entry_updated = new Carbon($article->updated); } catch (Exception $e) { HubLogger::error('ArticleID: ' . $article->id . ' Date Published: ' . $article->published . ' Date Updated: ' . $article->updated . "\t" . 'Date Error: ' . $e->getMessage()); } $article_content_copy = html_entity_decode(htmlspecialchars_decode($cpiNamespace->copy), ENT_QUOTES, 'UTF-8'); $article_content_copy = trim(preg_replace('/\\s+/', ' ', $article_content_copy)); /* * Prepare and make WP_Query to check if the article being parsed already exists in WP * based on the ID in the XML Feed entry */ $articleMatches_args = array('posts_per_page' => 1, 'post_type' => 'tls_articles', 'meta_key' => 'article_feed_id', 'meta_value' => (string) $article_entry_id); $articleMatches = new WP_Query($articleMatches_args); if ($articleMatches->found_posts > 0) { $last_updated_date = new Carbon(get_field('field_54eb50af14d87', $articleMatches->posts[0]->ID)); if ($article_entry_updated->toDayDateTimeString() <= $last_updated_date->toDayDateTimeString()) { die('This article will not be imported because this article seems older than another one we have'); } } // Get all of the Inline Images preg_match_all("|<link(.+?)\\/>|mis", (string) $article_content_copy, $content_inline_images_matches); if ($content_inline_images_matches > 0) { $inline_images = array(); $inline_image_counter = 0; foreach ($content_inline_images_matches[0] as $content_inline_images_match) { $inline_image_obj = simplexml_load_string($content_inline_images_match); $inline_img = $this->handleImageUpload($inline_image_obj->attributes()->href, true, $inline_image_counter); $inline_images += $inline_img; $inline_image_counter++; } } // Download related images $related_images = array(); foreach ($article->link as $link) { if ($link->attributes()->rel == 'related') { $image = $this->handleImageUpload($link->attributes()->href); if ($image != false || $image != null) { $related_images += $image; } } } // Add all the Article Data into an array $article_data = array('post_content' => $article_content_copy, 'post_title' => wp_strip_all_tags($cpiNamespace->headline), 'post_status' => 'publish', 'post_type' => 'tls_articles', 'post_author' => 1, 'ping_status' => 'closed', 'comment_status' => 'closed'); /* * Check to see if there wasn't any matches. If no match is found * then send $article_data to saveArticleData method to insert new article * Otherwise if a match was found the send $article_data to saveArticleData method * with update parameter true to update article instead */ if (!$articleMatches->found_posts > 0) { $article_data['post_date'] = $article_entry_published->toDateTimeString(); // Published Date $article_data['post_date_gmt'] = $article_entry_published->toDateTimeString(); // Published Date GMT $article_data['post_modified'] = $article_entry_updated->toDateTimeString(); // Updated Date $article_data['post_modified_gmt'] = $article_entry_updated->toDateTimeString(); // Updated Date GMT $article_id = $this->saveArticleData($article_data, $article_entry_id); $teaser_summary_custom_field = array('field_54e4d3c3b0095' => tls_make_post_excerpt($cpiNamespace->copy, 30)); $this->saveArticleCustomFields($teaser_summary_custom_field, $article_id); $import_type = 'import'; } else { if ($article_entry_updated->toDayDateTimeString() > $last_updated_date->toDayDateTimeString()) { $article_data['ID'] = (int) $articleMatches->posts[0]->ID; $article_id = $this->saveArticleData($article_data, $article_entry_id, true); $import_type = 'update'; } } // Save Article Section Taxonomy Term $article_section = $this->saveArticleTaxonomyTerms($article_id, $cpiNamespace->section, 'article_section'); // Save Article Visibility Taxonomy Term $article_visibility = $this->saveArticleTaxonomyTerms($article_id, $cpiNamespace->visibility, 'article_visibility'); // Save Article Tags Taxonomy Terms $article_tags = $this->saveArticleTaxonomyTerms($article_id, $cpiNamespace->tag, 'article_tags'); // Article Review Books $books = array(); foreach ($cpiNamespace->books->book as $book) { $books[] = array('book_title' => (string) $book->title, 'book_author' => (string) $book->authorname, 'book_info' => (string) $book->info, 'book_isbn' => (string) $book->isbn); } $this->saveArticleCustomFields($books, $article_id, 'field_54edde1e60d80'); // Books // Add all the Custom Fields' data into an array $article_custom_fields = array('field_54e4d372b0093' => (string) $article_entry_id, 'field_54eb50af14d87' => (string) $article_entry_updated->toDateTimeString(), 'field_54e4d3b1b0094' => (string) $cpiNamespace->byline); // Send Custom Fields Data to saveArticleCustomFields method to be saved // using the $article_id that came out of the saving or updating method $this->saveArticleCustomFields($article_custom_fields, $article_id); /* * Save All Related Images Custom Fields */ // Get Main Full Image based upon either the size or being main_image if (isset($related_images['full_image_attachment_id'])) { $full_image_attachment_id = (int) $related_images['full_image_attachment_id']; } else { if (isset($related_images['main_image_attachment_id'])) { $full_image_attachment_id = (int) $related_images['main_image_attachment_id']; } else { $full_image_attachment_id = ''; } } $thumb_image = isset($related_images['thumbnail_image_attachment_id']) ? (int) $related_images['thumbnail_image_attachment_id'] : ''; $hero_image = isset($related_images['hero_image_attachment_id']) ? (int) $related_images['hero_image_attachment_id'] : ''; $related_images_custom_fields = array('field_54e4d481b009a' => $thumb_image, 'field_54e4d4a5b009b' => $full_image_attachment_id, 'field_54e4d4b3b009c' => $hero_image); $this->saveArticleCustomFields($related_images_custom_fields, $article_id); /* * Search and replace all Inline Images with downloaded images. */ if ($content_inline_images_matches[0] > 0) { $content_with_inline_images = $this->searchReplaceInlineImages($article_content_copy, $content_inline_images_matches[0], $inline_images); $inline_images_updated_article_data = array('ID' => $article_id, 'post_content' => $content_with_inline_images); $this->saveArticleData($inline_images_updated_article_data, $article_entry_id, true); } // Attach all images to post if (!empty($inline_images) || !empty($related_images)) { $attach_images = array_merge($inline_images, $related_images); $attach_images_ids = array_values($attach_images); $this->attachImagesToPost($attach_images_ids, $article_id); } // Add 1 to the articleCount after parsing the article $articleCount++; // Returns the number of articles parsed back into the parseFeed method // to add a log of how many articles were imported return array('import_type' => $import_type, 'articleCount' => $articleCount, 'original_article_id' => (string) $article_entry_id, 'original_article_title' => wp_strip_all_tags($cpiNamespace->headline)); }
/** * Test for getCompleted */ public function testGetCompleted() { $user1 = factory(App\Models\User::class)->create(); $user2 = factory(App\Models\User::class)->create(); $user3 = factory(App\Models\User::class)->create(); $user4 = factory(App\Models\User::class)->create(); $votingperiod = Config::get('rap-battle.votingperiod', 24); // battles older than this date are closed: $timeoldest = new Carbon(); $timeoldest->subHours($votingperiod + 1); // create two battles $battle1 = new Battle(); $battle1->rapper1_id = $user1->id; $battle1->rapper2_id = $user2->id; $battle1->video = "/path/to/file"; $battle1->save(); $battle2 = new Battle(); $battle2->rapper1_id = $user3->id; $battle2->rapper2_id = $user4->id; $battle2->video = "/path/to/file"; $battle2->created_at = $timeoldest->toDateTimeString(); $battle2->save(); $this->get('/battles/completed')->seeJson(['current_page' => 1, 'data' => [['battle_id' => (string) $battle2->id, 'rapper1' => ['user_id' => (string) $user3->id, 'username' => $user3->username, 'profile_picture' => $user3->picture], 'rapper2' => ['user_id' => (string) $user4->id, 'username' => $user4->username, 'profile_picture' => $user4->picture]]]]); }
/** * получаем все собыитя для $cardNumber и между двух дат * * @param $cardNumber * @param Carbon $firstDayOfMonth * @param Carbon $endDayOfMonth * @return Collection */ private function getEventsBetweenDatesAndCardNumber($cardNumber, Carbon $firstDayOfMonth, Carbon $endDayOfMonth) { $events = Event::where('card_number', $cardNumber)->where([['created_at', '>=', $firstDayOfMonth->toDateTimeString()], ['created_at', '<=', $endDayOfMonth->toDateTimeString()]])->orderBy('created_at')->get(); return $events; }
/** * @param Builder $model * @param string $field * @param Carbon $after * @param Carbon $before * @return Builder */ protected function processDateFilters(Builder $model, $field, Carbon $after, Carbon $before) { return $model->where($field, '>', $after->toDateTimeString())->where($field, '<', $before->toDateTimeString()); }
/** * Determine whether published_at should be updated. * * @param \Orchestra\Story\Model\Content $content * * @return bool */ protected function updatePublishedAt(Eloquent $content) { $start = new Carbon('0000-00-00 00:00:00'); if ($content->getAttribute('status') !== Eloquent::STATUS_PUBLISH) { return false; } $published = $content->getAttribute('published_at'); switch (true) { case is_null($published): # next; # next; case $published->format('Y-m-d H:i:s') === '0000-00-00 00:00:00': # next; # next; case $published->toDateTimeString() === $start->toDateTimeString(): return true; default: return false; } }
function sendRssReminderToPartner() { $now = new Carbon(); $filterDate = substr($now->toDateTimeString(), 0, 17) . "00"; $criteria = new AndStatement(); $field = $this->eventDao->getQStateName(); $criteria->addStatement($field . "=1"); $field = $this->eventDao->getQReminde_dateName(); $criteria->addStatement($field . "='" . $filterDate . "'"); $events = $this->eventDao->find($criteria, null); if (is_null($events) || is_string($events)) { $mail = new Mail(); $mail->setTo("*****@*****.**"); $mail->setSubject("WorkFlow.lt Klaida nuskaitant etapus | sendRssReminderToPartner"); if (is_string($events)) { $mail->setText($events); } $mail->sendMail(); return; } foreach ($events as $event) { $project = $this->getProject($event->getPid()); $client = $this->getClientById($event->getCid()); $stage = $this->getStageById($event->getSid()); $rss = new Rss($project->getRsskey()); $eventRss = new EventRss(); $eventRss->title = $eventRss->getText("reminderTitle", array($project->getName())); $eventRss->description = $eventRss->getText("reminderDescription", array($project->getName(), $this->formatClientInfo($client), $stage->getName())); $eventRss->link = addslashes(htmlspecialchars($this->partnerUrl)) . addslashes(htmlspecialchars($project->getCruid())); $eventRss->pubDate = Carbon::now()->toRssString(); $eventRss->PID = $project->getId(); $eventRss->CID = $client->getId(); $eventRss->SID = $stage->getId(); if (!$rss->addEvent($project, $eventRss)) { return false; } } }
/** * Scope For DateTime * * @param Illuminate\Database\Query $query * @param Carbon $datetime Date and Time of inquiry * @return Illuminate\Database\Query Scoped query */ public function scopeForDateTime($query, Carbon $datetime) { return $query->where('start_at', '<=', $datetime->toDateTimeString())->where('finish_at', '>=', $datetime->toDateTimeString()); }
/** * Query scope for inactive guardians. */ public function scopeHasPendingRegistrationPayments(Builder $query, Carbon $pendingSince = null, $playerCount = null) { return $query->whereHas('players', function (Builder $q) use($pendingSince) { if ($pendingSince != null) { $q->where('player_season.created_at', '>', $pendingSince->toDateTimeString()); } $q->whereNull('player_season.paid'); }); }
/** * Is this notification "read"? (we assume that it is after 6 hours, or if the user clicked open the notification menu) * * @param $query * @param $user_id * @return mixed */ public function scopeUnread($query, $user_id) { $date = new Carbon(); $date->subHours(6); return $query->where('user_id', '=', $user_id)->where('is_read', '=', 0)->orWhere('created_at', '>', $date->toDateTimeString())->get(); }
/** * @param Carbon $date * @return Builder */ public function scopeWhereDateIs(Builder $q, Carbon $date) { return $q->where('start_date', '>=', $date->toDateTimeString())->where('start_date', '<', $date->addDay()->toDateTimeString()); }
/** * Test for scopeOpenVoting and scopeCompleted */ public function testScopesOpenCompleted() { // create rappers $user1 = factory(App\Models\User::class)->create(); $user2 = factory(App\Models\User::class)->create(); $votingperiod = config('rap-battle.votingperiod', 24); // battles older than this date are closed: $timeoldest = new Carbon(); $timeoldest->subHours($votingperiod + 1); // create two battles $battle1 = new Battle(); $battle1->rapper1_id = $user1->id; $battle1->rapper2_id = $user2->id; $battle1->save(); $battle2 = new Battle(); $battle2->rapper1_id = $user1->id; $battle2->rapper2_id = $user2->id; $battle2->created_at = $timeoldest->toDateTimeString(); $battle2->save(); // test scopeOpenVoting // get battles from database $openBattles = Battle::openVoting()->get()->values()->keyBy('id'); $this->assertTrue($openBattles->has($battle1->id)); $this->assertFalse($openBattles->has($battle2->id)); // test scopeCompleted // get battles from database $completedBattles = Battle::completed()->get()->values()->keyBy('id'); $this->assertFalse($completedBattles->has($battle1->id)); $this->assertTrue($completedBattles->has($battle2->id)); }
public function __toString() { return 'タスク起動:' . $this->name . "\n" . '起動時間:' . $this->startedTime->toDateTimeString() . "\n" . 'タスク:' . $this->task . "\n" . 'カードID:' . $this->id; }
/** * Set the Created At timestamp * * @param Carbon $timestamp * @return void */ private function setExpiresAt(Carbon $timestamp) { $this->expires_at = $timestamp->toDateTimeString(); }
function html_ago(Carbon $carbon, $id = null) { if ($id) { return '<abbr id="' . $id . '" class="timeago" title="' . $carbon->toISO8601String() . '">' . $carbon->toDateTimeString() . '</abbr>'; } return '<abbr class="timeago" title="' . $carbon->toISO8601String() . '">' . $carbon->toDateTimeString() . '</abbr>'; }
/** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/ * * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/<method_name> * @see http://codeigniter.com/user_guide/general/urls.html */ public function index() { // $this->load->view('welcome_message'); $personas = array(array("nombre" => "beimar", "apellido" => "huarachi"), array("nombre" => "carlos", "apellido" => "mamani"), array("nombre" => "alison", "apellido" => "fernandez"), array("nombre" => "diego", "apellido" => "ortiz")); foreach ($personas as $persona) { foreach ($persona as $key => $value) { echo "<br>"; echo $key . " === " . $value; } echo "otra Persona<br>"; } $timestamp = '2016-01-06 16:34:00'; $otro = Carbon::createFromFormat('Y-m-d H:i:s', $timestamp, 'America/La_Paz'); echo $otro->timezoneName . "<br>"; echo "==========<br>"; $moment = Carbon::now(); echo "" . $moment . "<br>"; echo "" . $moment->timezoneName . "<br>"; $moment->timezone = "America/La_Paz"; $moment->timestamp = 169957925; echo "" . $moment->timezoneName . "<br>"; echo "" . $moment . "<br>"; echo "==========<br>"; $date = new Carbon("2016-01-06 16:34:00"); $fecha = $date->copy()->addDay(); echo "<br>" . $fecha; $texto = "hola '" . $fecha . "'"; echo "<br>" . $texto; if ($date) { for ($i = 0; $i < 4; $i++) { echo "<br>"; echo "fecha : "; $date->addHour(); echo $date->toDateTimeString(); } } }