How would I do this?

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
Watch

JoshHendo

Established Member
Impact
7
Hello. Does anyone know how I would go about getting the date from the previous day in PHP? I can get the current days date using:
$date = date("dmY");
(that is the format that I want it)
though if i wanted yesturdays date, that would be harder to get becuase the days system isn't based on 100 (grr to whoever made the date system ). If anyone could help me that would be great

(eg. If i tried 03112005 - 1 it would = 03112004 )

---

I tried: $yesturday = mktime(0, 0, 0, date("m") , date("d")-1, date("Y"));
though that didn't work the way I wanted :'(
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
This will work for you:
Code:
<?php
$date = date("dmY", time()-86400);
?>
Or:
Code:
<?php
$date = date("dmY", time()-(60*60*24));
?>
The second bit of code is 60 seconds times 60, which equals one hour, then that one hour times 24 - which is one day.
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com
Catchy
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back