Jump to content

future date with relation to mysql date


funbinod

Recommended Posts

i came to learn that future and past dates are calculated with the simple use of "strtotime()".

 

but this is calculated in relating with current date. i want to know if a future date can be calculated in relation with database stored date?

 

for example, if '2014-01-01' is stored in database, how can i get the date of 30 days(i.e.-2014-01-30) ahead from this date?

Link to comment
Share on other sites

You can use PHP's DateTime and DateTimeInterval classes to add or remove days, or you can convert it to a Unix timestamp and just add. 1 days is 86400 seconds, so you can multiply the number of days by that and add it to the timestamp. You can use functions like date or getdate to format the date for display.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...