PHP tutorials
Question:
Suppose you have a website where you need to set or display an expiry date 7 days from todays date. How do you do that?
Answer:
The technique is to add 7 days as represented in seconds to todays date as represented in UNIX timestamp and then convert the result into a date format you want.
Example
$today = date('U');
$days7 = 7 * 86400;
$end_date = $today + $days7;
echo '<p>Library book is due back on the ' . date('dS of F Y', $end_date) . '</p>';
Additional Notes
86400 is the number of seconds in a day.
PHP Reference Manual
date - Returns a formatted date
Comments or questions relating to this article have been disabled. They will be back soon.
Copyright
Let notice be given that this is copyright information