[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

adding or sutracting dates

Posted on 2000-03-15
6
Medium Priority
?
182 Views
Last Modified: 2008-03-17
how to add or subtract two given dates using php

please help with example if possible

Thanks
0
Comment
Question by:qader99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2619330
hmm give me examples of what you wish and need
For example : 03-15-2000 + 03-18-2000 = ?????
Could you explain ?
thanks
0
 
LVL 1

Expert Comment

by:aikon
ID: 2619477
Hi gader99,

Plz try to be more explicit.

Are they numeric or string data?

Regards.
0
 

Author Comment

by:qader99
ID: 2619717
Yes uss111 I want to do something similar to your example.
basically I have two date in (Y-m-d) format and I want to subtract them and get the number of days between them.
for example (2000-03-15)-(200-02-29) = 15 (days)

One of the two dates one is todays date which is derived from date('Y-m-d') function. And the other is derived by concatinating certain variables which make up a valid date.

Thanks
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Accepted Solution

by:
maxkir earned 40 total points
ID: 2619790
Well, may be it costs a little bit more then 10 points ;-)))

$year = 2000;
$mon = 1;
$day = 4;
$start_date = mktime(0,0,0, $mon, $day, $year);

$result_days = intval( (time() - $start_date)/(3600*24) );
echo $result_days;
0
 
LVL 8

Expert Comment

by:us111
ID: 2619874
hmm I don't think so, it's enough :)
0
 

Author Comment

by:qader99
ID: 2639682
Thank You
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

650 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