Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

652
Views
PHP Carbon does not calculate the time difference

I need to get the time difference.But carbon does not calculate.

date1  2022-03-30 00:00:00   
date2  2022-03-30 21:00:00  

$interval = $date1->diffInSeconds($date2);            -> OUTPUT: 0
$interval2 = $date1->diffAsCarbonInterval($date2);    -> OUTPUT: 
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You should parse all the data with Carbon to convert it to Carbon instance, then you can get the difference

 $diffInSeconds = Carbon\Carbon::parse('2022-03-30 00:00:00')->diffInSeconds(Carbon\Carbon::parse('2022-03-30 21:00:00'));
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!