How to create message on login page if yearly usae remains between 10 to 0 days in php mysql?

I need to display message on login page like “You have 10 days remaining to renew” on 10 days before it expires, if not renewed it will continue like you have 9 days remaining… and so on. once renewed date is reset like renewal activated, it message will now show up. How it can be done in php mysql or using JS? Thanks for the help.

Both MySql and php have datediff functions that calculate the number of days between two dates. See https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_datediff and https://www.php.net/manual/en/datetime.diff.php

1 Like

I use something like this to force a user to update their profile page if they have not during the last six months. You can change it to handle ten days like the second example…

// Check the last time they visited their profile page. If over six months then go to profile page.
if ($user[“last_updated”]<=date(“Y-m-d H:i:s”, strtotime("-6 months"))) header(“Location: Profile.php”);

For your use, something loosely like this in PHP would work…

if ($current_date <= date(“Y-m-d H:i:s”, strtotime("-10 days"))) { do something… }

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service