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

x
?
Solved

Timestamp Equation

Posted on 2006-06-01
8
Medium Priority
?
298 Views
Last Modified: 2008-03-03
I want to add two weeks to a timestamp- What's the easiest way to do this?
0
Comment
Question by:blizzdek
  • 3
  • 2
6 Comments
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16813325
$newtimestamp  = time() + 1209600;
0
 
LVL 10

Expert Comment

by:ClickCentric
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

by:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:anilande
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.
for mysql add time function check the link below
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
0
 
LVL 40

Expert Comment

by:Richard Quadling
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

by:Richard Quadling
Richard Quadling earned 648 total points
ID: 16814674
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question