I Need Help with a FUTURE DATE Script.. But I'm No Programmer

11 replies
Hey guys..

I went crazy on google earlier tryin to find a date script that will display the Thursday of the current week...

for example.. if today is Saturday, December 5, 2009... the website displays Thursday, December 10, 2009..

Is it possible.. and can anyone help a warrior out?

Hector...
#date #future #programmer #script
  • Profile picture of the author m4rx
    Well what kind of script do you need. Do you need one programmed in JS, PHP, ASP. If you need a specific one that would be good, if not, I may be able to shoot out a php one. Not too sure how useful this script is, but everyone needs something different.
    :]

    --m4rx
    Signature
    We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle
    Bored. Learn everything you need to know about Organic Gardening.
    {{ DiscussionBoard.errors[1463657].message }}
  • Profile picture of the author HomeBizNizz
    PHP Tutorial - Date

    D: Day of the week abbreviations. Sun through Sat
    l: Day of the week. Values Sunday through Saturday
    w: Day of the week without leading zeroes. Values 0 through 6.
    {{ DiscussionBoard.errors[1463849].message }}
  • Profile picture of the author Mr. Enthusiastic
    Originally Posted by Hecman104 View Post

    Hey guys..

    I went crazy on google earlier tryin to find a date script that will display the Thursday of the current week...

    for example.. if today is Saturday, December 5, 2009... the website displays Thursday, December 10, 2009..

    Is it possible.. and can anyone help a warrior out?

    Hector...
    Hi Hector, what you need will be something like this:

    $daysUntilThursday = 0;
    switch (date("l") {
    case "Wednesday": $daysUntilThursday = 1; break;
    case "Tuesday": $daysUntilThursday = 2; break;
    case "Monday": $daysUntilThursday = 3; break;
    case "Sunday": $daysUntilThursday = 4; break;
    case "Saturday": $daysUntilThursday = 5; break;
    case "Friday": $daysUntilThursday = 6; break;
    default:
    // today is Thursday
    $daysUntilThursday = 0;
    }
    $ThursdayToShow = date_add($date, new DateInterval("P" + $daysUntilThursday + "D"));
    echo "Your Thursday update is due on " + date("m/d/y",$ThursdayToShow)

    You will need to adapt this to your needs and debug it, but I think it will get you most of the way there.

    Chris
    {{ DiscussionBoard.errors[1464476].message }}
  • Profile picture of the author m4rx
    That is perfect, and quite along the lines of the one I was making before 'work' but the problem is that DateInterval isn't available until 5.3, as of which I know some webhost's don't have, so Hecman104 may have some problems.

    --m4rx
    Signature
    We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle
    Bored. Learn everything you need to know about Organic Gardening.
    {{ DiscussionBoard.errors[1465083].message }}
  • Profile picture of the author m4rx
    Got It. This has no extensive testing, but should work for what you need it for.
    It need's nothing but the basics, and if you want to see it for yourself, here's a link.
    http://tylerperroux.com/portfolio/date.php


    PHP Code:
    <?php
    global  ;
    // Set Timezone
    date_default_timezone_set('UTC');

    // Explicitly set days until the next thursday
     
    0;
    switch (
    date('l')) {

        case 
    'Friday'
             = 
    6
        break;
        case 
    'Saturday'
             = 
    5
        break;
        case 
    'Sunday':     
             = 
    4
        break;
        case 
    'Monday'
             = 
    3
        break;
        case 
    'Tuesday'
             = 
    2
        break;
        case 
    'Wednesday':
             = 
    1
        break;
        default:
        
    // today is Thursday
             
    0;
        break;
    }

    // Add to the number in the current month
    // This get's it into the right week so we can have a proper date
     
    date('d') + ;

    // Is the number over 30/31
    if( > cal_days_in_month(CAL_GREGORIANdate(n), date('Y'))){

        
    // Will fix the day int. (ex. 35 > 31(dec), so 35-31= 4, thursday is the 4th
         
    =  - cal_days_in_month(CAL_GREGORIANdate(n), date('Y'));

    }
    // There it is
    // All nice and organized. 
    // Will output "Thursday 10th of December 2009 is the next thursday"
    echo date('l jS of F Y'mktime(000date(n), , date(Y)))." is the next thursday";
    Enjoi :]

    --m4rx
    Signature
    We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle
    Bored. Learn everything you need to know about Organic Gardening.
    {{ DiscussionBoard.errors[1465137].message }}
  • Profile picture of the author Mr. Enthusiastic
    Thanks Tyler, I made a sketch on a napkin and you turned it into some snazzy code.
    {{ DiscussionBoard.errors[1466939].message }}
    • Profile picture of the author MemberCon
      strtotime FTW

      <?php
      echo date('l, F j, Y', strtotime('this Thursday'));
      ?>

      Will print today's date, if today is Thursday, although if today is Friday, it will print next Thursday's date, which may not be your intent. You may have intended to print yesterday's date, if today is Friday.
      {{ DiscussionBoard.errors[1468427].message }}
  • Profile picture of the author Mr. Enthusiastic
    Oh, that's slick, MemberCon guys. (Is it both of you behind the user name here?) I occasionally tinker to patch up a php script, but I'm not a die-hard php developer and it never occured to me to look for a function like this. Hector might only need that one line.
    {{ DiscussionBoard.errors[1470344].message }}
  • Profile picture of the author Hecman104
    Wow.. sorry guys.. I've been real busy and couldn't reply bck..

    YES YES YES YES.. thank you MemberCon.. that's exactly it.. i need for it to give me the next thursday..

    I kno I might've confused a few with my initial post but.. I found the script that did what I asked for and then realized that I needed it to tell me next week's thursday if it was friday or saturday....

    So thank you MemberCon.... and all the other warriors for helping out.. there are some really talented people on here

    -Hector
    Signature
    Get 3 Free Reports To Grow You Blogging Business

    Click Here >> www.HectorJCuevas.Com
    {{ DiscussionBoard.errors[1473274].message }}
  • Profile picture of the author m4rx
    Very Very nice.
    Never acctually had to deal with time, so I have little idea on how to use the PHP functions.

    Love the one line, so much less complicated than mine :]

    --m4rx
    Signature
    We are what we repeatedly do. Excellence, then, is not an act, but a HABIT. ~Aristotle
    Bored. Learn everything you need to know about Organic Gardening.
    {{ DiscussionBoard.errors[1477273].message }}
  • Profile picture of the author rodrick
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[1477845].message }}
  • Profile picture of the author customertools
    The easy way:
    Code:
    echo 'Next Week: '. date('l, F j, Y', strtotime('+1 week'));
    {{ DiscussionBoard.errors[1497877].message }}

Trending Topics