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 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    creating backlogs of files depending on the date

    I'm looking for directions on a problem with creating some files.

    Here's the gist of what I am trying to do.

    Look into a file and check if file exists. If it doesn't exist create the file.

    Essentially I am trying to create a file for every week for the past 2 years.

    each time I create the file its suppose to have the date of each week appended to it

    ie) file naming structure:
    PHP Code:
     "randomtext_"$startweek '_' $endweek.'.php'
    PHP Code:
    <?php

    define
    ("SRV_RT",realpath(dirname(__FILE__).'/..'));    

    $end_curr_week mktime(0,0,0,date("m"), date("d") + (-date("w")+6), date("Y"));  // Current week (saturday)
    $first_week mktime(0,0,0,1,1,2010); 
    $diff $end_curr_week $first_week;  // figure out how many weeks there are from current week to  Jan 1, 2010. 

    $numofweek=($diff / (7*24*60*60));
    echo 
    $numofweek// checking my number

    /*$filepath = SRV_RT. "/randomtext_". $startweek . '_' . $endweek.'.php'; 
    if (file_exists($filepath)) { exit;}
    else{$Handle = fopen($filepath, "w+") or die("can't open file");  } */

    $num 0;
    while (
    $num <= $numofweek){
    $num++;
    $list$num 7;
    echo 
    $list'<br>';
    }

    $period_start =  mktime(0,0,0,date("m"), date("d") + ((-date("w"))-$list), date("Y")); // start of current week

    $period_end =  mktime(0,0,0,date("m"), date("d") + ((-date("w")+6)-$list), date("Y"));

    $end_week date('Ymd'$period_end);
    $start_week date('Ymd'$period_start);

    ?>
    That's just some things I been thinking about. I thought if I figure out how many numbers of week there are in the past years I can use that to change my $period_start and $period_end.

    PHP Code:
    $period_start =  mktime(0,0,0,date("m"), date("d") + ((-date("w"))-[B]$list[/B]), date("Y")); // start of week

    $period_end =  mktime(0,0,0,date("m"), date("d") + ((-date("w")+6)-[B]$list[/B]), date("Y")); End of week 
    Only problem is I don't know how to get the period start and period end to keep looping until Jan 01, 2010.

    Am I doing this the wrong way? I really need $period_start and $period_end to change for every week for the past to 2 years.


    I figured it out nvm. Put the date into an array, so simple.
    Last edited by phpnoobtv; 01-18-2012 at 08:57 PM. Reason: RESOLVEd


 

Posting Permissions

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