Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    74
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Code to get dates that are 3 full working days previous

    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.

    Thanks
    Rob

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Strtotime is best for this.
    PHP Code:
    $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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    New Coder
    Join Date
    Jul 2008
    Posts
    74
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Hi
    I have been trying variations of this
    Code:
     $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.

    Thanks
    Rob

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    74
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Sorted.
    Many Thanks for the pointers
    Last edited by robbiez; 11-27-2010 at 11:03 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •