本文整理汇总了PHP中Carbon\Carbon::setToStringFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::setToStringFormat方法的具体用法?PHP Carbon::setToStringFormat怎么用?PHP Carbon::setToStringFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon\Carbon
的用法示例。
在下文中一共展示了Carbon::setToStringFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Create a new command instance.
*
* @return void
*/
public function __construct(TrackingRepository $trackingRepo, BillboardRepository $billboardRepo)
{
parent::__construct();
$this->trackingRepository = $trackingRepo;
$this->billboardRepository = $billboardRepo;
Carbon::setToStringFormat('Y_m');
}
示例2: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
\Carbon\Carbon::setToStringFormat('d/m/Y');
view()->composer('admin.templates.principal', function ($view) {
$view->with('usuario', auth()->user());
});
}
示例3: testResetToStringFormat
public function testResetToStringFormat()
{
$d = Carbon::now();
Carbon::setToStringFormat('123');
Carbon::resetToStringFormat();
$this->assertSame($d->toDateTimeString(), '' . $d);
}
示例4: __construct
public function __construct(array $data)
{
if (class_exists('\\Carbon\\Carbon')) {
$format = 'D, d M o H:i:s e';
\Carbon\Carbon::setToStringFormat($format);
}
parent::__construct($data);
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$locale = $request->cookie('locale', Config::get('app.locale'));
App::setLocale($locale);
Carbon::setLocale($locale);
Carbon::setToStringFormat('Y-m-d H:i:s');
return $next($request);
}
示例6: feedhistory
function feedhistory($connection = 'default', $limit)
{
$annotations = Annotation::on($connection)->with('Attachments')->where('id', '<', $limit)->orderBy('id', 'desc')->take(20)->get();
Carbon::setToStringFormat(DateTime::ISO8601);
$result = [];
foreach ($annotations as $annotation) {
$result[] = json_decode($annotation->toJson());
}
return json_encode($result);
}
示例7: __construct
public function __construct(array $data)
{
if (class_exists('\\Carbon\\Carbon')) {
$format = 'D, d M o H:i:s e';
\Carbon\Carbon::setToStringFormat($format);
}
parent::__construct($data);
if (isset($this->data['discussion'])) {
$this->discussion = new Discussion($this->data['discussion']);
}
}
示例8: __construct
public function __construct($data = null, $status = 200, $headers = array(), $options = 0)
{
if ($data instanceof \Exception) {
$data = array("code" => $data->getCode(), "error" => $data->getMessage());
} else {
// move the prepare function here
Carbon::setToStringFormat('Y-m-d\\TH:i:s.z\\Z');
$data = ParseHelper::prepareResponse($data);
}
parent::__construct($data, $status, $headers, $options);
}
示例9: getCheck
public function getCheck()
{
$meds = \WQS\Medication::all();
foreach ($meds as $med) {
$taken = Carbon::parse($med->last_taken);
if ($med->interval < Carbon::now()->diffInHours($taken)) {
$med->can_take = 1;
}
Carbon::setToStringFormat('g:i a');
$med->next = $taken->addHours($med->interval);
}
return view('med-check')->with('meds', $meds);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('auth/login');
}
}
// Also set locale per request
app()->setLocale($this->auth->user()->locale);
// And set default string format for dates
Carbon::setToStringFormat('j-M-Y h:i A');
return $next($request);
}
示例11: getAllMessages
public function getAllMessages()
{
try {
Carbon::setToStringFormat(self::PLUGIN_DATE_FORMAT);
$date_from = Carbon::now()->subMonth()->toDateString();
$date_to = Carbon::now()->toDateString();
$mandrill = new Mandrill($this->getSetting('MandrillApiKey'));
$result = $mandrill->messages->search('*', $date_from, $date_to);
} catch (Mandrill_Error $e) {
// Mandrill errors are thrown as exceptions
// echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
// A mandrill error occurred: Mandrill_ServiceUnavailable - Service Temporarily Unavailable
throw $e;
}
return $result;
}
示例12: getAttributeValue
/**
* Get a plain attribute (not a relationship).
*
* @param string $key
* @return mixed
*/
protected function getAttributeValue($key)
{
$value = $this->getAttributeFromArray($key);
// If the attribute has a get mutator, we will call that then return what
// it returns as the value, which is useful for transforming values on
// retrieval from the model to a form that is more useful for usage.
if ($this->hasGetMutator($key)) {
return $this->mutateAttribute($key, $value);
} elseif (in_array($key, $this->getDateField())) {
if ($value) {
Carbon::setToStringFormat('d-m-Y');
return (new Carbon($value, 'US/Eastern'))->setTimezone('Asia/Kuala_Lumpur');
}
} elseif (in_array($key, $this->getDateTimeField())) {
if ($value) {
Carbon::setToStringFormat('d-m-Y H:i:s');
return (new Carbon($value, 'US/Eastern'))->setTimezone('Asia/Kuala_Lumpur');
}
}
return $value;
}
示例13: doRun
/**
* Runs the current application.
*
* @param InputInterface $input An Input instance
* @param OutputInterface $output An Output instance
*
* @return int 0 if everything went fine, or an error code
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
$name = $this->getCommandName($input);
// Did the user enter an environment option?
if (true === $input->hasParameterOption(['--env', '-e'])) {
$this->environment = $input->getParameterOption(['--env', '-e']);
} else {
if ($name === 'publish') {
$this->environment = 'production';
}
}
// Load config
$this->config = new Config($this->environment);
// Set local timezone
date_default_timezone_set($this->getSetting('timezone', 'America/New_York'));
// Set default date format
Carbon::setToStringFormat($this->config->get('date_format', 'Y-m-d H:i:s'));
// Register events
$this->registerEvents();
return parent::doRun($input, $output);
}
示例14: __construct
public function __construct()
{
$this->query = \App\Statcache::Week()->get();
\Carbon\Carbon::setToStringFormat('d/m/Y');
}
示例15: __construct
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
Carbon::setToStringFormat('Y_m');
}