php-carbon

Carbon Difference in Time between two Dates in hh:mm:ss format

╄→гoц情女王★ 提交于 2019-11-26 19:49:29
问题 I'm trying to figure out how I can take two date time strings that are stored in our database and convert it to a difference in time format of hh:mm:ss. I looked at diffForHumans , but that does give the format I'd like and returns things like after , ago , etc; which is useful, but not for what I'm trying to do. The duration will never span days, only a max of a couple hours. $startTime = Carbon::parse($this->start_time); $finishTime = Carbon::parse($this->finish_time); $totalDuration =

Calculate difference between two dates using Carbon and Blade

孤人 提交于 2019-11-26 16:48:51
问题 Does anyone know how to pass a given variable instead the Carbon's default parameters ? The documentation of Carbon says: // CARBON SAMPLE $dtToronto = Carbon::createFromDate(2012, 1, 1, 'America/Toronto'); $dtVancouver = Carbon::createFromDate(2012, 1, 1, 'America/Vancouver'); echo $dtVancouver->diffInHours($dtToronto); // 3 And i want to do something like this in my controller: // EXAMPLE $date = "2016-09-16 11:00:00"; $datework = Carbon::createFromDate($date); $now = Carbon::now();

How to compare two Carbon Timestamps?

[亡魂溺海] 提交于 2019-11-26 12:37:32
问题 I have two timestamps, edited_at which I created and created_at (Laravel\'s)... In database, both have type timestamp and default value 0000-00-00 00:00:00... But var_dump(edited_at variable) is giving string. While var_dump(created_at variable) is object/Carbon. What is wrong with these timestamps? I have to compare both after converting into integer using format(\'U\'). I can only call this method on Carbon Object. How can I do that? 回答1: First, Eloquent automatically converts it's