[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
Solved

# Timestamp Equation

Posted on 2006-06-01
Medium Priority
298 Views
I want to add two weeks to a timestamp- What's the easiest way to do this?
0
Question by:blizzdek
• 3
• 2

LVL 10

Expert Comment

ID: 16813325
\$newtimestamp  = time() + 1209600;
0

LVL 10

Expert Comment

ID: 16813333
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

LVL 10

Accepted Solution

ClickCentric earned 652 total points
ID: 16813337
Umm...just so no one corrects me, don't actually multiple by the '2' in '2 weeks'
0

LVL 4

Expert Comment

ID: 16813587
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.
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
0

LVL 40

Expert Comment

ID: 16814663
<?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

LVL 40

Assisted Solution

Richard Quadling earned 648 total points
ID: 16814674
Ah.

<?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

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
###### Suggested Courses
Course of the Month19 days, 15 hours left to enroll