The time() function returns the current timestamp in seconds. (For a more accurate time you can use the microtime() function.) By adding or subtracting the number of seconds from the output of the time() function, you find the amount of time from now until some future or past time.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"> <head> <title>time()</title> <meta Name="Author" Content="Hann So"> </head> <body> <p> <?php echo time(), "<br />"; echo time() + (7 *24*60*60), "<br />"; // next week in seconds echo date("M-d-Y", time()), "<br />"; // today echo date("M-d-Y", time() + (7*24*60*60)), "<br />"; // next week echo date("M-d-Y", time() - (7*24*60*60)), "<br />"; // last week ?> </p> </body> </html> |