I am currently working on a package manager for my current project and I need to add package subscription date and package expiry date.
I am using php function date("Y-m-d H:i:s") i.e
$package_subscription_start_date = date("Y-m-d H:i:s");
now here is my requirement:
I need to have packages such as for 1 day, 2 days, 5 days, 1 week, 4 weeks, 12 weeks, 1 month, 6 months, 9 months, 1 year, 2 years, 5years and 10 years.
How is it possible for me to add these values and calculate the package expiry date for inserting into mysql, something like
$package_expiry_date = date("Y-m-d H:i:s") + 1 day;
$package_expiry_date = date("Y-m-d H:i:s") + 5 days;
$package_expiry_date = date("Y-m-d H:i:s") + 1 week;
$package_expiry_date = date("Y-m-d H:i:s") + 4 weeks;
$package_expiry_date = date("Y-m-d H:i:s") + 2 months;
$package_expiry_date = date("Y-m-d H:i:s") + 2 years;
Lastly I need to take care of other date issues like valid date and leap year etc.
Also I need this to be done at php level, not using mysql / sql query.
I will appreciate any help in this direction.
Have you tried the strtotime() command in php?
Gives you the output of