I a using PHP and would like the date of third day before the script is called in the format of YYYYMMDD. How can I do this?
Asked
Active
Viewed 6,727 times
1
-
1have you tried anything so far? – Arijit Mukherjee Jul 22 '14 at 06:38
-
strtotime function in php documentation will lead you there... – Sumit Gupta Jul 22 '14 at 06:41
-
Refer this link [get next and previous day](http://stackoverflow.com/questions/5883571/get-next-and-previous-day-with-php) – Talk2Nit Jul 22 '14 at 06:58
4 Answers
2
Use DateTime
:
$date = new \DateTime('-3 days');
echo $date->format('Ymd');
// Alternatively, store the string in a variable
$result = $date->format('Ymd');

rink.attendant.6
- 44,500
- 61
- 101
- 156