How can I count the number of months from the following two dates below using the Procedural style method?
PHP code.
$delete_date = "2000-01-12 08:02:39";
$current_date = date('Y-m-d H:i:s'); //current date
You're looking for DateTime::diff?
$delete_date = "2000-01-12 08:02:39";
$date_format = 'Y-m-d H:i:s';
$current_date = date($date_format);
$diff = date_diff(date_create_from_format($date_format, $delete_date), date_create());
$months = $diff->m;
Something along the lines of that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With