set day in future

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

set day in future

Post by psychotomus »

I want to run polls for a certain ammount of time.

how do I add the number of days to time() ??

time() + $days?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

<?php
$ts = time();
echo date('Y-m-d', $ts), "<br />\n";

$ts = strtotime('tomorrow');
echo date('Y-m-d', $ts), "<br />\n";

$ts = strtotime('+1 day');
echo date('Y-m-d', $ts), "<br />\n";

$ts = strtotime('+2 day');
echo date('Y-m-d', $ts), "<br />\n";

$ts = strtotime('+2 week');
echo date('Y-m-d', $ts), "<br />\n";

$ts = strtotime('next thursday');
echo date('Y-m-d', $ts), "<br />\n";

$ts = strtotime('next friday');
echo date('Y-m-d', $ts), "<br />\n";
?>
see http://de2.php.net/strtotime
Post Reply