Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

date calculation

Posted on 2004-08-04
8
Medium Priority
?
175 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
[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
  • 2
  • 2
8 Comments
 
LVL 25

Accepted Solution

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

Expert Comment

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

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.

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 look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

610 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