RE: [PHP] Date calculations
| From: | Jason Murray | Date: | Tue, 12 Sep 2000 08:13:42 +0000 |
| Subject: | RE: [PHP] Date calculations | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-16283@lists.php.net to get a copy of this message | ||
> What I am trying to do is take the current date then try to
> get the date from four days back. For instance, today is the
> 12th September, I want the system to look at this, subtract
> four days off, and get the 8th September in the format
> 2000-09-08 [date ("y-m-d)].
$currentdate = Date("U"); // Unix timestamp, seconds since 1970.
$minute = 60; // Seconds in a minute
$hour = 60*$minute; // Minutes in an hour
$day = 24*$hour; // Hours in a day
$dayfour = 4*$day; // Days in 4 days (duh)
$datefourdaysago = $currentdate - $dayfour; // Unix timestamp 4 days ago.
$dateoutput = date("Y-m-D", $datefoursaysago);
Have fun :)
Jason