• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

adding or sutracting dates

how to add or subtract two given dates using php

please help with example if possible

Thanks
0
qader99
Asked:
qader99
1 Solution
 
us111Commented:
hmm give me examples of what you wish and need
For example : 03-15-2000 + 03-18-2000 = ?????
Could you explain ?
thanks
0
 
aikonCommented:
Hi gader99,

Plz try to be more explicit.

Are they numeric or string data?

Regards.
0
 
qader99Author Commented:
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
maxkirCommented:
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
 
us111Commented:
hmm I don't think so, it's enough :)
0
 
qader99Author Commented:
Thank You
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.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now