如何添加一天并同时为该日期指定静态时间?

How can I add a day and at the same time specify a static time for that date?

很好,我有一个问题,我希望你能帮助我,事实是我必须从我的数据库中获取一些时间戳并在某一天添加​​它们,好吧,好吧,我使用 carbon addday () ,但由于 carbon 不想比较我的时间戳,所以我必须转换为字符串,通过解析我可以将它们同化为 carbon,但在那个过程中我的日期发生了变化,日期都是正常的,但由于某种原因时间加起来了到几个小时,这完全改变了我正在寻找的结果,我该如何解决? 我通过我的命令:

<?php

namespace App\Console\Commands;

use App\p;
use App\Pe;
use App\Mail\SendMailable;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use Carbon\Carbon;
class LimpiarDiario extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'Task:LD';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Tasks';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
       $datedi = p::select('p.Date', 'p.coddate')
               ->where('p.cod_paperiod', '=', 1)
               ->get();
           foreach ($datedi as $dateda)
            {
                $cod = $dateda->coddate;
           $now = Carbon::now();
            $dateli = $dateda->Date;
            $dateinter = strtotime($dateli);
           $datecar = Carbon::Parse($dateinter);
           $datetrans = $datecar->addDay();
           $datenue= $datetrans->toDateTimeString();
           if ($dateda->Date < $now)
            {
           $prueba= p::where('coddate','=', $cod)
           ->update(['Date' => $datenue]);

           }

           }
        }

为了显示问题,我的 dateda 的结果是:{"Date":"2020-06-12 16:00:00.000000","coddate":53} 然后就变成了dateli,它的值为:2020-06-12 16:00:00.000000 它再次变成 dateinter 并且它的值是:1591992000 最后它变成了带有变量 datecar 的碳:"2020-06-13T20:00:00.000000Z" 正如您现在看到的,出于某种原因,它比原来的时间增加了 4 小时,所以当我注册结果时,它为我节省了日期:2020-06-13 20:00:00

当期望的结果应该是:2020-06-12 16:00:00

所以正如所解释的,我必须寻求帮助才能知道如何设置解析时间或如何在不更改时间的情况下将其转换为时间戳。

PHP生成的时间基于服务器配置的时间,而javascript生成的时间基于您当前的设备。

为什么所有这些脚本只是为了更新语句...

$now=Carbon::now();

p::where('p.cod_paperiod', '=', 1)->where('date','<',$now)
    ->update(['Date' => DB::raw("Date + INTERVAL 1 DAY")]);