本文整理汇总了PHP中Carbon::format方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::format方法的具体用法?PHP Carbon::format怎么用?PHP Carbon::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon
的用法示例。
在下文中一共展示了Carbon::format方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReportAffiliate
public function ReportAffiliate($token)
{
$header = array(array('INSTITUCION DE PREVISION SOCIAL DEL PERIODISTA'), array('Carnet: ', '', ' Fecha Nacimiento: ', ' ', 'Edad: ', 'Fecha Ingreso: '), array('Nombre: '), array('Tiempo de jubilación Voluntaria: '), array('Tiempo de jubilación Obligatorio: '), array('Pago de Cuotas Sector Privado '), array(''), array('Año', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'));
$dues = $this->duesRepository->getModel()->where('affiliate_id', $affiliate->id)->orderBy('date_payment', 'ASC')->get();
if (!$dues->isEmpty()) {
//"01/01/1995"
$old_year = Carbon::format($dues[0]->date_payment)->getFullYear();
//1995
$last_year = Carbon::format($dues[count($dues) - 1])->getFullYear();
//2014
for ($i = $old_year; $i <= $last_year; $i++) {
$row[] = $i;
for ($j = 1; $j <= 12; $j++) {
# code...
foreach ($dues as $key => $value) {
if ($value->date_payment == "01/" . $j . "/" . $i) {
array_push($row, $value->amount);
} else {
array_push($row, "");
}
}
}
array_push($header, $row);
}
}
echo json_encode($header);
die;
/* foreach ($dues as $due) {
$duesYear = $this->duesRepository->getModel()->where('date_payment',$affiliate->id)->where('affiliate_id',$affiliate->id)->orderBy('date_payment','ASC')->get();
foreach(){
$header[] = ['Año','Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'];
}
}*/
}
示例2: niceDateRange
public function niceDateRange(Carbon $date1 = null, Carbon $date2 = null, $ordinalSuffixRequired = false)
{
$ordinalSuffix = "";
$day1 = $date1->day;
$day2 = $date2->day;
$month1 = $date1->month;
$month2 = $date2->month;
//$ordinalSuffix = FormatMe::toOrdinalSuffix($day2);
$restOfDate = $date2->format('F Y');
$myDateString = "{$day1}-{$day2}" . $ordinalSuffix;
// if months are not the same, display both months in range
if ($month1 !== $month2) {
return "{$day1} " . $date1->format('F') . " – " . "{$day2} " . $date2->format('F Y');
}
return $myDateString . ' ' . $restOfDate;
}
示例3: dueDate
public function dueDate()
{
$settings = APSetting::first();
$generated_on = new Carbon($this->generated_on);
$generated_on->addDays($settings->payment_due_in_days);
return $generated_on->format('d M y');
}
示例4: calculateHolidays
private function calculateHolidays($country, $fromYear, $toYear)
{
$return = [];
if ($fromYear == $toYear) {
$years = [$fromYear];
} else {
$years = [$fromYear, $toYear];
}
foreach ($years as $year) {
$country_file = dirname(__DIR__) . '/data/' . $country . '.json';
$countryHolidays = json_decode(file_get_contents($country_file), true);
foreach ($countryHolidays as $countryHoliday) {
if (strstr($countryHoliday['rule'], '%Y')) {
$rule = str_replace('%Y', $year, $countryHoliday['rule']);
} elseif (strstr($countryHoliday['rule'], '%EASTER')) {
$date = new Carbon($year . '-03-21 +' . easter_days($year) . ' days');
$rule = str_replace('%EASTER', $date->format('Y-m-d'), $countryHoliday['rule']);
} elseif (in_array($country, ['BR', 'US']) && strstr($countryHoliday['rule'], '%ELECTION')) {
$rule = $this->calculateElectionDay($country, $years, $year, $countryHoliday);
} else {
$rule = $countryHoliday['rule'] . ' ' . $year;
}
if ($rule) {
$return[] = ['name' => $countryHoliday['name'], 'date' => new Carbon($rule)];
}
}
}
return $return;
}
示例5: isBirthday
/**
* Check if its the birthday. Compares the date/month values of the two dates.
*
* @param Carbon $dt
*
* @return boolean
*/
public function isBirthday(Carbon $dt)
{
return $this->format('md') === $dt->format('md');
}
示例6: migrarRecaudosSolicitud
private function migrarRecaudosSolicitud()
{
$this->info("Migrando recaudos de la solicitud");
$this->getTable('recaudos_solicitud')->chunk(1000, function ($recaudos) {
foreach ($recaudos as $recaudo) {
$this->info("Migrando recaudo de la solicitud: " . $recaudo->codrecaudo);
$recaudoNuevo = new RecaudoSolicitud();
$recaudoNuevo->recaudo_id = $recaudo->codrecaudo;
$recaudoNuevo->solicitud_id = $recaudo->idsolicitud;
$recaudoNuevo->ind_recibido = $recaudo->indrecibido == 'S';
if ($recaudo->fecvencimiento != '') {
$carbon = new Carbon($recaudo->fecvencimiento);
$recaudoNuevo->fecha_vencimiento = $carbon->format('d/m/Y');
}
$recaudoNuevo->save();
}
});
}
示例7: formatTime
function formatTime(Carbon $time)
{
return $time->format('H:i');
}