View Full Version : Code to get dates that are 3 full working days previous

11-25-2010, 10:10 PM
Sorry, can't get my head round this and could do with some help.

Bascially my admin panel shows tabular data of my outstanding orders. What I want to do is highlight(by changing the text color) orders that were taken 3 full working days ago.

I have the following data available in seperate columns:
Epochtime, Day of month, Month, Year.

What I need is a function that puts a gets the order date plus 3 full working days so I can compare it to todays date. Then I can change the text color with if ($duedate == $todaysdate){....}

Orders taken on Monday would need the $duedate to be Thursday,
Tuesday $duedate = Friday
Wednesday $duedate=Monday
Thursday $duedate=Tuesday
Friday/Saturday/Sunday = Wednesday

All our orders are cleared within a week, so there would be no overlap of days.


11-26-2010, 12:51 AM
Strtotime is best for this.

$threeDays = strtotime('+3 day', $epochtime);

That will give you a timestamp that is 3 days after the $epochtime. Comparing that to today, if its result is < 0, then you are not past three days. Otherwise, 3 days have elapsed. Thats a bad comparison I guess, since it depends on how you compare >.<
Just try to get the $threeDays from that, and go from there to see which way is the way you are comparing. It will either be < or > 0 lol.

11-26-2010, 09:17 AM
I have been trying variations of this

$epochtime = $dborder['epochorder'];
$threeDays = strtotime('+3 day', $epochtime);
print $threeDays;

but all that does is print the epochtime (+ 3 days).

How can I get Mon, Tues, Weds, etc from the epochtime.

If I can get the day I can use a switch statement to get to the Due Date.


11-26-2010, 07:04 PM
I see what you mean.
Using a timestamp can be done in a few ways, with date and formatting, or with getDate are two good ways. I'd use getDate since you then have access to all the other parts of the timestamp as a date as well: http://php.ca/manual/en/function.getdate.php

To compare the day of week, I'd recommend using it as a number with wday (0-6). This gives you more portability since it now becomes language (I mean spoken language) independent instead of comparing 'Monday', 'Tuesday' and so forth.

11-27-2010, 09:03 AM
Many Thanks for the pointers

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum