How to perform calculations on a given day of week? Specifically, I want to compare a given time value, say given_date, with a given day of week of a given week, say, next Friday. If I want to perf...
See more...
How to perform calculations on a given day of week? Specifically, I want to compare a given time value, say given_date, with a given day of week of a given week, say, next Friday. If I want to perform the calculation, say, for a week from now, I can use if(given_date > time() + 7 * 86400, "later", "earlier") (This can be easily adjusted for beginning of day, etc.) If today is Friday, the above will tell me whether given_date is earlier than or later than next Friday. But if today is Monday, it only tells me whether it is earlier or later than next Monday. For event data, I can extract day of week from date_wday. Is there a calculator/function to do that for arbitrary time value? I suppose I can use strftime(time(), "%w") to determine delta from desired day of week, then add/subtract whole weeks to the desired day of week. (Unlike date_wday, strftime() gives a numeric value that is easy for calculation.) Is there a more direct way?