Solved

date calculation

Posted on 2004-08-04
8
158 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:
Squinky 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:Squinky
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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.

708 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

15 Experts available now in Live!

Get 1:1 Help Now