本文整理汇总了PHP中Carbon\Carbon::toDateString方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::toDateString方法的具体用法?PHP Carbon::toDateString怎么用?PHP Carbon::toDateString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::toDateString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getByDate
public function getByDate(Carbon $date)
{
$return = null;
if (isset($this->workingDays[$date->toDateString()])) {
$return = $this->workingDays[$date->toDateString()];
}
return $return;
}
示例2: addSlotsForDay
private function addSlotsForDay(Carbon $day)
{
$result = '';
$courts = [3, 4, 5, 6];
$hours = [15, 16, 17, 18];
foreach ($courts as $key => $court) {
foreach ($hours as $key => $hour) {
if (!Slot::where('day', $day->toDateString())->where('court', $court)->where('hour', $hour)->count()) {
$result .= $day->toDateString() . ', Bana ' . $court . ', kl ' . $hour . ':00 tillagd som slot.<br/>';
Slot::create(['day' => $day->toDateString(), 'hour' => $hour, 'court' => $court]);
}
}
}
return $result;
}
示例3: store
public function store($projectId, Request $request)
{
$date = new Carbon($request->date);
$project = Project::findOrFail($projectId);
$project->costEstimations()->create(['settled_at' => $date]);
return redirect()->route('projects.cost-estimations.show', [$projectId, $date->toDateString()]);
}
示例4: pay
/**
* Pay billet by billet id.
*
* @param int $billet_id
* @param Carbon $date
*
* @return Billet
*/
public function pay($billet_id, Carbon $date)
{
$model = $this->model;
$billet = $model->find($billet_id);
if (!is_null($billet->discharge_date)) {
throw new RepositoryException("You can't pay this billet");
}
$billet->discharge_date = $date->toDateString();
$billet->save();
return $billet;
}
示例5: index
public function index(Request $request)
{
$now = new Carbon();
if ($request->isMethod('post')) {
$from = new Carbon($request->input('from', $now->toDateString()));
$to = new Carbon($request->input('to', $now->toDateString()));
$lessons = \App\Lesson::orderBy('given_at', 'asc')->where('given_at', '>=', $from->startOfDay()->toDateTimeString())->where('given_at', '<=', $to->endOfDay()->toDateTimeString())->get();
} else {
$lessons = \App\Lesson::orderBy('given_at', 'asc')->get();
}
$groups = \App\CustomerGroup::orderBy('groupname', 'desc')->get();
return view('lesson.index')->with(['lessons' => $lessons, 'groups' => $groups, 'now' => $now->toDateString(), 'from' => isset($from) ? $from->toDateString() : '', 'to' => isset($to) ? $to->toDateString() : '']);
}
示例6: filterByDate
public function filterByDate(Carbon $date)
{
$lists = $this->listService->all();
$todayTasks = new ArrayList();
foreach ($lists as $list) {
$tasks = new ArrayList($this->forList($list));
$listTasks = $tasks->filter(function (Task $task) use($date) {
if ($task->getDueDate()) {
$taskDate = Carbon::instance($task->getDueDate());
return $taskDate->toDateString() === $date->toDateString();
}
});
$todayTasks->concat($listTasks);
}
return $todayTasks;
}
示例7: testRegister
public function testRegister()
{
$birthday = new Carbon();
$birthday->addYear(-23);
$this->visit('/auth/register')->type('user1', 'name')->type('user1@case.edu', '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' => 'user1@case.edu', 'bdate' => $birthday->toDateString(), 'gender' => '0', 'daily_calories' => '2000']);
$user = \App\User::whereEmail('user1@case.edu')->first();
foreach ($restrictions as $restriction) {
if ($map[$restriction->id] == 1) {
$this->seeInDatabase('restriction_user', ['user_id' => $user->id, 'restriction_id' => $restriction->id]);
}
}
}
示例8: scopeOfDate
/**
* Scope of date.
*
* @param Illuminate\Database\Query $query
* @param Carbon $date
*
* @return Illuminate\Database\Query
*/
public function scopeOfDate($query, Carbon $date)
{
$date->timezone('UTC');
return $query->whereRaw('date(`start_at`) = ?', [$date->toDateString()]);
}
示例9: getDate
protected function getDate($value)
{
if ($value) {
$d = new Carbon($value);
return $d->toDateString();
} else {
return null;
}
}
示例10: Carbon
require_once 'vendor/autoload.php';
use Carbon\Carbon;
use Citco\Carbon as CitcoCarbon;
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");
示例11: test_suspend_company_with_command_on_expiration_date
public function test_suspend_company_with_command_on_expiration_date()
{
$expirationDate = new Carbon('2017-06-30');
$company = factory(Company::class)->create();
$user = factory(User::class, 'admin')->create();
$this->actingAs($user)->visit('/company/' . $company->id . '/edit')->see($company->name)->see('name="licence_expire_at"')->type($expirationDate->toDateString(), 'licence_expire_at')->press('Save Edit')->seeInDatabase('companies', ['id' => $company->id, 'licence_expire_at' => $expirationDate->toDateString(), 'is_suspended' => false])->seeInDatabase('schedules', ['who_object' => Company::class, 'who_id' => $company->id, 'run_at' => $expirationDate->toDateString(), 'action' => ActionCommandSuspendCompanyCommand::class]);
// enter to testing time - set date to be expiration date
Carbon::setTestNow($expirationDate);
$company = Company::findOrFail($company->id);
$this->assertEquals(false, $company->is_suspended);
$results = \App\Model\ActionQueue\ActionCommandScheduled::run();
$company = Company::findOrFail($company->id);
$this->assertEquals(true, $company->is_suspended);
// exit from testing time - reset current time
Carbon::setTestNow();
}
示例12: sendEmailContact
public function sendEmailContact(Request $request)
{
$email = userAdmin::where('identidad', $request->identidad)->first();
$ent = entidadTuristica::where('rif', $request->identidad)->first();
$camas = new camas();
$hab = new habitacion();
$email = $email->email;
// Buscando habitaciones para el email de respaldo de la persona
// todo este codigo deberia estar en una función aparte -- mejorar modularidad en codigo para futuros proyectos.
$legalMessage = "";
$f = "";
$f2 = "";
if ($ent->tipoentidad == "Hotel") {
$habitaciones = habitacion::where('identidad', $request->identidad)->get();
$camas = $camas->camasPorHabitacion($habitaciones);
$habitaciones = $hab->serviciosOrdenados($habitaciones);
$desde = Carbon::now();
$desdeInicio = Carbon::create($desde->year, $desde->month, 1);
$desdeFin = Carbon::create($desde->year, $desde->month, $desde->daysInMonth);
$desdeInicio = $desdeInicio->toDateString();
$desdeFin = $desdeFin->toDateString();
$dias = 1;
$legalMessage = "NOTA: Las tarifas son validas desde el " . $desdeInicio . " hasta el " . $desdeFin . " y las mismas estan sujetas a cambios.";
if (Session::has('fecha')) {
$fecha = explode(" - ", Session::get('fecha'));
$f = new Carbon($fecha[0]);
$f2 = new Carbon($fecha[1]);
$dias = $f->diffInDays($f2);
$query = " SELECT idperfilhabitacion FROM habitacionesperfil WHERE id NOT IN ( SELECT disponibilidad.idhabitacion from disponibilidad WHERE (estado = 'Habilitado')\n AND ((disponibilidad.fecha_inicio BETWEEN '" . $fecha[0] . "' AND '" . $fecha[1] . "')\n OR (disponibilidad.fecha_fin BETWEEN '" . $fecha[0] . "' AND '" . $fecha[1] . "')\n OR ( ('" . $fecha[0] . "' >= disponibilidad.fecha_inicio) AND ('" . $fecha[1] . "' <= disponibilidad.fecha_fin) ) ) ) ";
$search = DB::select(DB::raw($query));
$arraySearch = [];
foreach ($search as $s) {
array_push($arraySearch, $s->idperfilhabitacion);
}
foreach ($habitaciones as $h) {
$h['disponible'] = in_array($h->id, $arraySearch);
}
}
foreach ($habitaciones as $h) {
$h['total'] = $dias * $h['tarifa'];
}
} else {
$habitaciones = null;
}
$data = ['nombre' => $request->nombre, "email" => $request->email, "telefono" => $request->telefono, "mensaje" => $request->mensaje];
$data2 = ['habitaciones' => $habitaciones, 'legalMessage' => $legalMessage, 'nombreEntidad' => $ent->nombre, 'f' => $f->toDateString(), 'f2' => $f2->toDateString()];
$response;
$statusCode;
try {
Mail::send('emails.contacto', $data, function ($message) use($email) {
$message->from(env('MAIL_USERNAME'), 'AppHoteles');
$message->subject('Contacto - AppHoteles');
// Aqui iria el titulo...
$message->to($email);
});
Mail::send('emails.usuarioContacto', $data2, function ($message) use($request) {
$message->from(env('MAIL_USERNAME'), 'AppHoteles');
$message->subject('Contacto - AppHoteles');
// Aqui iria el titulo...
$message->to($request->email);
});
$response = ['success' => true, 'message' => 'Email enviado.'];
$statusCode = 200;
} catch (Exception $e) {
$response = ["error" => $e->getMessage()];
$statusCode = 400;
} finally {
return Response::json($response, $statusCode);
}
}
示例13: getByDate
public function getByDate(Carbon $date)
{
$repo = $this->em->getRepository('JGimeno\\TaskReporter\\Domain\\Entity\\WorkingDay');
$return = $repo->findOneByDate($date->toDateString());
return $return;
}
示例14: buildTimeCardRangeVar
/**
* @param $bwDate
* @param $ewDate
*
* @return string
*/
protected function buildTimeCardRangeVar(Carbon $bwDate, Carbon $ewDate)
{
$timeCardRange = '( ' . $bwDate->toDateString() . ' - ' . $ewDate->toDateString() . ' )';
return $timeCardRange;
}
示例15: buildPayload
/**
* @param $data
* @return array
*/
private function buildPayload($data)
{
$payload = ['id' => (int) $data[0], 'name' => trim($data[1]), 'account_type_id' => (int) $data[2], 'account_status_id' => (int) $data[3], 'contact_name' => trim($data[16])];
$unformattedAddress = ['line1' => trim($data[7]), 'line2' => trim($data[8]), 'city' => trim($data[9]), 'state' => trim($data[10]), 'county' => trim($data[11]), 'zip' => trim($data[12]), 'country' => trim($data[13]), 'latitude' => trim($data[14]), 'longitude' => trim($data[15])];
$formattedAddress = $this->addressFormatter->formatAddress($unformattedAddress, false);
$payload = array_merge($payload, $formattedAddress);
/**
* We don't do a ton of validation here, as the API call will fail if this data is invalid anyway.
*/
if (trim($data[4])) {
$payload['account_groups'] = explode(",", trim($data[4]));
}
if (trim($data[5])) {
$payload['sub_accounts'] = explode(",", trim($data[5]));
}
if (trim($data[6])) {
$carbon = new Carbon($data[6]);
$now = Carbon::now();
if ($carbon->gt($now)) {
$payload['next_bill_date'] = trim($carbon->toDateString());
}
}
if (trim($data[17])) {
$payload['role'] = trim($data[17]);
}
if (trim($data[18])) {
$payload['email_address'] = trim($data[18]);
}
if (trim($data[19])) {
$payload['email_message_categories'] = explode(",", trim($data[19]));
} else {
$payload['email_message_categories'] = [];
}
$phoneNumbers = [];
if (trim($data[20])) {
$phoneNumbers['work'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[20])), 'extension' => trim($data[21])];
}
if (trim($data[22])) {
$phoneNumbers['home'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[22])), 'extension' => null];
}
if (trim($data[23])) {
$phoneNumbers['mobile'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[23])), 'extension' => null];
}
if (trim($data[24])) {
$phoneNumbers['fax'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[24])), 'extension' => null];
}
if (count($phoneNumbers) > 0) {
$payload['phone_numbers'] = $phoneNumbers;
}
return $payload;
}