Solved

date calculation

Posted on 2004-08-04
8
170 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 20 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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.

691 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