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.
There is a many solutions but here is one my solution that working well in the most cases.

```
function current_week ($date = NULL) {
    if($date) {
        if(is_numeric($date) && ctype_digit($date) && strtotime(date('Y-m-d H:i:s',$date)) === (int)$date)
            $unix_timestamp = $date;
        else
            $unix_timestamp = strtotime($date);
    } else $unix_timestamp = time();

    return (ceil((date('d', $unix_timestamp) - date('w', $unix_timestamp) - 1) / 7) + 1);
}

```

It accept unix timestamp, normal date or return current week from the `time()` if you not pass any value.

Enjoy!