Timestamp Equation

I want to add two weeks to a timestamp- What's the easiest way to do this?
blizzdekAsked:
Who is Participating?
 
ClickCentricCommented:
Umm...just so no one corrects me, don't actually multiple by the '2' in '2 weeks'
0
 
ClickCentricCommented:
$newtimestamp  = time() + 1209600;
0
 
ClickCentricCommented:
60 seconds in a minute, 60 minutes in an hour, 24 hours in a day and 14 days in 2 weeks..just multiply them all together and add them to the current time.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
anilandeCommented:
i will sugest u to use mysql for this task.
since some times the php timestamp format is different that the mysql timestamp format which creats problem in future or if u want to upgrade mysql 4 to 5 the timestamp format may create prob.
for mysql add time function check the link below
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
0
 
Richard QuadlingSenior Software DeveloperCommented:
<?php
echo date('r') . "\n" . date('r', strtotime('+2 weeks'));
?>

results in ...

Fri, 02 Jun 2006 09:05:22 +0100
Fri, 16 Jun 2006 09:05:22 +0100

which is 2 weeks different.

0
 
Richard QuadlingSenior Software DeveloperCommented:
Ah.

Real answer ...

<?php
$dt_timestamp = time();
$dt_2weeks = strtotime('+2 weeks', $dt_timestamp);

echo date('r', $dt_timestamp) . "\n" . date('r', $dt_2weeks);
?>

results in ...

Fri, 02 Jun 2006 09:07:34 +0100
Fri, 16 Jun 2006 09:07:34 +0100

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.