calculate the time difference between two times in hours and minutes php OR Add or Subtract days, month and year to a date using PHP
calculate the time difference between two times in hours and minutes php
Use Mathematical Formulas and Use date_diff() Function to Get Time Difference in Minutes in PHP Examples. get hours difference between two dates in php. Get Hours/Months Time Difference Between Two Dates In Laravel
$hourdiff = round((strtotime($time1) - strtotime($time2))/3600, 1);
1. Add days to date
The following example shows how to add 7 days to date.
// Result: 2022-12-07
Add 15 days to the current date.
// Result: 2023-01-21
Add 1 month to date.
// Result: 2023-02-06
Add 1 year to date.
// Result: 2021-01-06
2. Subtract days from date
how to subtract 5 days from date.
// Result: 2022-12-30
Subtract 2 days from current date.
// Result: 2023-01-04
Subtract 1 month from date.
// Result: 2022-12-06
Subtract 1 year from date.
// Result: 2022-01-06
I hope you get an idea about calculate the time difference between two times in hours and minutes php.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.