我有Maxoffer模特:
protected $dates = [
'start'
];
public function setStartAttribute($date){
$this->attributes['start']= Carbon::createFromFormat('m/d/Y h:i a', $date);
}
public function getStartAttribute($date){
return (new Carbon($date))->toRfc2822String();
}
在我的数据库中start
的格式为:2016-02-02 00:00:00
现在,当我尝试运行WHERE
查询时:
$maxoffer = Maxoffer::where('article_id', $request->input('article_id'))
->where('start', $request->input('start'))
->first();
dd($maxoffer);
Input(start)
格式:2016-02-02 12:00 am我也尝试以这种格式制作:2016-02-02 00:00:00但是再次不工作所以dd给我结果null
我遇到了一个问题因为我不知道如何比较开始和输入(开始)。如何以相同的格式制作它们......
我也无法改变:
public function getStartAttribute($date){
return (new Carbon($date))->toRfc2822String();
}
因为我需要这种格式用于其他事情。
那么如何才能实现这一目标?
答案 0 :(得分:1)
在下面尝试将字符串转换为碳时间和Eloquent然后可以比较DB中的时间
#include <stdio.h>
#include <conio.h>
void plus_func();
void menus_func();
void mul_func();
void div_func();
void modulus_func();
void shiftleft_func();
void shiftright_func();
void and_func();
void or_func();
void not_func();
void doubleand_func();
void doubleor_func();
void notequal_func();
void xor_func();
void main(void){
int x,y, res;
int m;
int op1;
int op2;
int op3;
int i=0;
int k;
while(i==0){
printf("Enter any key to start the calculator function program or escape to exit it \n");
k=getch();
if(k!=0x1b)
{
printf("enter the first num or press escape to exit \n");
x=getch();
if(x==0x1b)
{
break;
}
else
{
op1=x-48;
}
printf("enter the second num or press escape to exit \n");
y=getch();
if(y==0x1b)
{
break;
}
else
{
op2=y-48;
}
printf("enter the type of the operation \n",m);
m=getch();
if(m==0x1b)
{
break;
}
else
{
op3=m-48;
}
switch(op3)
{
case 1: plus_func(op1,op2);break;
case 2: menus_func(op1,op2);break;
case 3: mul_func(op1,op2);break;
case 4: div_func(op1,op2);break;
case 5: modulus_func(op1,op2);break;
case 6: shiftleft_func(op1,op2);break;
case 7: shiftright_func(op1,op2);break;
case 8: and_func(op1,op2);break;
case 9: or_func(op1,op2);break;
case 10: not_func(op1,op2);break;
case 11: doubleand_func(op1,op2);break;
case 12: doubleor_func(op1,op2);break;
case 13: notequal_func(op1,op2);break;
case 14: xor_func(op1,op2);break;
default: printf("error");
break;
}
}
else
{
break;
}
}
}
void plus_func(int a, int b)
{
int c;
c=a+b;
printf("the result is %d \n",c);
}
void menus_func(int a, int b)
{
int c;
c=a-b;
printf("the result is %d \n",c);
}
void mul_func(int a, int b)
{
int c;
c=a*b;
printf("the result is %d \n",c);
}
void div_func(int a, int b)
{
int c;
c=a/b;
printf("the result is %d \n",c);
}
void modulus_func(int a, int b)
{
int c;
c=a%b;
printf("the result is %d \n",c);
}
void shiftleft_func(int a, int b){
int c;
c=a<<b;
printf("the result is %d \n",c);
}
void shiftright_func(int a, int b)
{
int c;
c=a>>b;
printf("the result is %d \n",c);
}
void and_func(int a, int b)
{
int c;
c=a&b;
printf("the result is %d \n",c);
}
void or_func(int a, int b)
{
int c;
c=a|b;
printf("the result is %d \n",c);
}
void not_func(int a, int b)
{
int c;
c=a+b;
c=~c;
printf("the result is %d \n",c);
}
void doubleand_func(int a, int b)
{
int c;
c=a&&b;
printf("the result is %d \n",c);
}
void doubleor_func(int a, int b)
{
int c;
c=a||b;
printf("the result is %d \n",c);
}
void notequal_func(int a, int b)
{
int c;
c=a+b;
c=!c;
printf("the result is %d \n",c);
}
void xor_func(int a, int b)
{
int c;
c=a^b;
printf("the result is %d \n",c);
}