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: 
```
function getWeekOfMonth(DateTime $date) {
    $firstDayOfMonth = new DateTime($date->format('Y-m-1'));

    return ceil(($firstDayOfMonth->format('N') + $date->format('j') - 1) / 7);
}

```

[Goendg solution](https://stackoverflow.com/a/33773342/5355492) does not work for 2016-10-31.
```
$month = 6;
$year = 2021;           
$week = date("W", strtotime($year . "-" . $month ."-01"));

$str='';
$str .= date("d-m-Y", strtotime($year . "-" . $month ."-01")) ."to";
$unix = strtotime($year."W".$week ."+1 week");
while(date("m", $unix) == $month){
 $str .= date("d-m-Y", $unix-86400) . "|";
 $str .= date("d-m-Y", $unix) ."to"; 
 $unix = $unix + (86400*7);
}
$str .= date("d-m-Y", strtotime("last day of ".$year . "-" . $month));

$weeks_ar = explode('|',$str);
echo '<pre>'; print_r($weeks_ar);

```

working fine.