Can strtotime() be used with other variables?
Can I use strtotime() with other variables... for example:
Could I then find "3 days before that" or various other things from the result given as the variable "lastMonday"?
$lastMonday = strtotime("last Monday");
It has to be executable from any day... So for example if it's sun/mon/tue/wed/thu and you want to find when the last Friday was and then count back to 4 days prior for the "monday" of last week and ALSO have separate variables displaying each day from last week (monday-sunday) and the current week... (or other weeks)
The second (optional) parameter is a UNIX timestamp integer, which is what strtotime() returns, so you could chain them together if needed, e.g.:
Since date() also accepts the same optional 2nd parameter, you could even output that result in "human readable" format as:
$dateTime = strtotime('-3 days', strtotime('Last Monday'));
echo date('Y-m-d H:i:s', strtotime('-3 days', strtotime('Last Monday')));
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)