[英]the condition of if and else are false and its jump to else directly and my data are true
$reqAmount = $service->price;
$useraa = auth()->user();
//$usersRl = DB::table('gift_card_services')->select('id')->get();
$usersDay1 = DB::table('gift_card_services')->select('created_at')->where('id',1)->get();
$usersDay4 = DB::table('gift_card_services')->select('created_at')->where('id',4)->get();
$usersDay7 = DB::table('gift_card_services')->select('created_at')->where('id',7)->get();
if ($useraa->username == "abdoumadris") {
// $reqAmount = ($service->price - 2);
if ($usersDay1 == "2022-10-07 19:56:20" ) {
$reqAmount = ($service->price - 2);
}
else if ($usersDay4 == "2022-10-07 19:57:20") {
$reqAmount = ($service->price - 6);
}
else if ($usersDay7 == "2022-10-07 19:59:00") {
$reqAmount = ($service->price - 10);
}else{
$reqAmount = ($service->price - 1);
}
}
i need to change the price for all product but its allways - 1我需要更改所有产品的价格,但它总是 - 1
i am sure 100% that my data are set correctly and the if condition is true, but it's override to else directly我 100% 确定我的数据设置正确并且 if 条件为真,但它直接覆盖到 else
It is a bit tricky to work with date/time.使用日期/时间有点棘手。 What you are comparing is a special string representation of format 'Ymd H:i:s'.您正在比较的是格式“Ymd H:i:s”的特殊字符串表示形式。 You should check if these dates are really also stored like that in the database.您应该检查这些日期是否真的也像数据库中那样存储。 This is not the way I would expect date/time to be stored.这不是我希望存储日期/时间的方式。
Please give a dump of $usersDay1, $usersDay4 and $usersDay7.请转储 $usersDay1、$usersDay4 和 $usersDay7。 If these are timestamps, you might need to bring them to a different format before comparing them to string representations.如果这些是时间戳,您可能需要将它们转换为不同的格式,然后再将它们与字符串表示形式进行比较。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.