我使用carbon将两个日期与今天的日期进行比较,但是我在一个名为weekday的数据库中还有另一个字段,其中包含以下值:
‘'MO’'TU‘'WE’
因此,我不仅希望按日期搜索和输出,还希望按工作日进行搜索,因此:
public function show($id)
{
$today = Carbon::now();
$weekday = //whatever carbon or something else has to retrieve today's day
$event = Event::with('busines
我的模型中有一个published_at字段,我将其设置为碳排放日期。
class Model {
protected $dates = ['published_at'];
....
public function setPublishedAtAttribute($val)
{
$this->attributes['published_at'] = \Carbon\Carbon::createFromTimeStamp(strtotime($val));
}
}
这是一个可由用户设置的字段。当
我尝试检查一个日期是否等于另一个日期,但我无法获得匹配,因为一旦通过"parse“代码,来自表单的日期格式就会变成不同的顺序。我需要格式化这个日期以查找匹配,下面是一个示例代码来显示我是如何尝试的:
...
// $ago will give me this date: 2016-12-09 00:00:00
$ago = Carbon\Carbon::today()->addDays(2); // Todays date + 2 days
//$request->datex has the date coming from a form with this f
我想将日期更改为格式('l‘),我的意思是在数组中添加日期名称,例如,2022-04-01,可以在其中添加日期名称吗?日期仍在表格2022-04-01中,如何添加日期的名称?当我像这样返回$holiday的结果时
我的index.blade.php代码
//to get date range from query start_date end_date
@php
$start_date = \Carbon\Carbon::parse(request()->query('start_date '))->format('Y-m-d
我看了几节Laracast课程,现在我正在建造我的第一个Laravel项目。我有几个有created_at和updated_at时间戳的雄辩模型。
对于显示正确的日期格式,Laravel有一个非常好的功能:访问器。但在每一个雄辩的模型中,我现在有两个这样的功能:
public function getUpdatedAtAttribute($value) {
return Carbon::parse($value)->format('d-m-Y H:i:s');
}
public function getCreatedAtAttribute($value) {
我在我的laravel项目中用法语返回日期有问题,
在我的模型中,我有以下方法:
public function getShowDateAttribute()
{
Carbon::setLocale('fr_FR');
return Carbon::parse($this->conference_date)->format('D d F Y');
}
但是日期还是用英语写的,
我也试过了
setLocale(LC_TIME,'fr_FR');
但是日期仍然是英文的。我也尝试过使用php date函数和localize
我认为,比在浏览器中使用默认格式的开发人员(如应用程序前端显示的)更多的开发人员需要区域设置日期格式,即2016年12月22日。
因此,我在我的Laravel项目中为标准日期做了一个小的特点,比如created_at、updated_at和deleted_at:
<?php
namespace App\Traits;
use Carbon\Carbon;
trait FormatDates
{
protected $localFormat = 'd.m.Y H:i';
// save the date in UTC format in DB ta
我从数据库的开始日期和结束日期之间从2属性找到数据。
这是sql代码
select * from period WHERE
priceId = 1788749 AND
'2018-05-07 02:00:00' BETWEEN startPeriod AND endPeriod
但是,我不知道我怎么能用在拉拉上
我在试着
$now = Carbon::now()->toDateTimeString();
$prod =DB::table('period')->where('priceId','=', 1788