Page 1 of 1

Create Expiration date function from current date

Posted: Mon Apr 14, 2008 11:18 pm
by cap2cap10
:banghead: Greetings phpiers. I'm kind of a newbie programmer and I need help creating a function that will take the current date and add a # of days to create an expiration date that can be stored in MySQL. Are there any pro up to the task?

Thanks in advance,

Batoe

Re: Create Expiration date function from current date

Posted: Tue Apr 15, 2008 1:17 am
by Christopher
The way these date calculations are usually done is to convert the date to a Unix timestamp. That is an integer that represents seconds since 1/1/1970. Once you have that then you can add 60*60*24 times the number of days to get to a date in the future. Finally, there are functions to convert back from a timestamp to a text date. Check the manual for the date/time functions. There are examples in the entry and user supplied examples.