Solved

date calculation

Posted on 2004-08-04
8
162 Views
Last Modified: 2008-03-06
can someone tell me how to add the current date with a digit?
Example:

2004-08-30 + 5 = 2004-07-04

thank you!!!
0
Comment
Question by:spacelife23
  • 2
  • 2
8 Comments
 
LVL 25

Accepted Solution

by:
Marcus Bointon earned 20 total points
ID: 11713352
$newdate = date('Y-m-d', strtotime('+5 day', strtotime('2004-08-30')));
0
 
LVL 26

Expert Comment

by:ushastry
ID: 11713839
0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 11713953
Be warned - That's an old article that doesn't cover the wonders of strtotime, instead writing reams of code that does less.
0
 
LVL 3

Expert Comment

by:jmsloan
ID: 11717663
Here is what i do

This works with the current date

$date1 = mktime (0,0,0,date("m") ,date("d")-5,date("Y"));
$date = date("m/d/y", $date1);

echo "$date";
0
 
LVL 3

Expert Comment

by:jmsloan
ID: 11717689
if you wanted it for a certain date you could do this

<?php

$date1 = mktime (0,0,0,date("8") ,date("4")-5,date("2004"));
$date = date("Y-d-m", $date1);

echo "$date";

?>
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now