Question: I am trying to compress a log file directory on my mac. The log directory exists.

For example /var/logs/my\_log\_dir/

I am trying to run something like:

```
$ tar –cpzf x.tar.gz /var/logs/my_log_dir

```

I also tried other variations such as compressing only one of the files in the log dir - no luck. All I get from my mac is:

```
Usage:
  List:    tar -tf <archive-filename>
  Extract: tar -xf <archive-filename>
  Create:  tar -cf <archive-filename> [filenames...]
  Help:    tar --help

```

Thoughts?

Answer: 
My function. The main idea: we would count amount of weeks passed from the month's first date to current. And the current week number would be the next one. Works on rule: "Week starts from monday" (for sunday-based type we need to transform the increasing algorithm)

```
function GetWeekNumberOfMonth ($date){
    echo $date -> format('d.m.Y');
    //define current year, month and day in numeric
    $_year = $date -> format('Y');
    $_month = $date -> format('n');
    $_day = $date -> format('j');
    $_week = 0; //count of weeks passed
    for ($i = 1; $i < $_day; $i++){
        echo "\n\n-->";
        $_newDate = mktime(0,0,1, $_month, $i, $_year);
        echo "\n";
        echo date("d.m.Y", $_newDate);
        echo "-->";
        echo date("N", $_newDate);
        //on sunday increasing weeks passed count
        if (date("N", $_newDate) == 7){
            echo "New week";
            $_week += 1;
        }

    }
    return $_week + 1; // as we are counting only passed weeks the current one would be on one higher
}

$date = new DateTime("2019-04-08");
echo "\n\nResult: ". GetWeekNumberOfMonth($date);

```
```
$date = new DateTime('first Monday of this month');
$thisMonth = $date->format('m');
$mondays_arr = [];

// Get all the Mondays in the current month and store in array
while ($date->format('m') === $thisMonth) {
    //echo $date->format('Y-m-d'), "\n";
    $mondays_arr[] = $date->format('d');
    $date->modify('next Monday');
}

// Get the day of the week (1-7 from monday to sunday)
$day_of_week = date('N') - 1;

// Get the day of month (1 to 31) 
$current_week_monday_date = date('j') - $day_of_week;

/*$day_of_week = date('N',mktime(0, 0, 0, 2, 11, 2020)) - 1;
$current_week_monday_date = date('j',mktime(0, 0, 0, 2, 11, 2020)) - $day_of_week;*/

$week_no = array_search($current_week_monday_date,$mondays_arr) + 1;
echo "Week No: ". $week_no;

```