# Solved: no leading zero in week of year?



## namenotfound (Apr 30, 2005)

Is there a way I can get the week of year with no leading zero?? W gives 2 digits with leading zeros and I don't know how to get it to display no leading zero.

```
<?php
echo "It is currently the " . date("WS") . " week of the year.";
?>
```
Will output



> It is currently the 08th week of the year.


How can I remove leading zeros?


----------



## Gibble (Oct 10, 2001)

simplest way is to put the _date("WS") _into a string, and check the first character of it, if it's a 0, ignore that part of the string with _substr_


----------



## namenotfound (Apr 30, 2005)

Good idea.

Ok that worked


----------



## brendandonhu (Jul 8, 2002)

You could put it in the same line

```
<?php
echo "It is currently the " . ltrim(date('WS'),0) . " week of the year.";
?>
```


----------



## Gibble (Oct 10, 2001)

Brendan...I completely forgot you could use ltrim to strip more than just whitespace.


----------



## brendandonhu (Jul 8, 2002)

It's useful


----------

