views:

229

answers:

2

Hi, i tried this:

echo date('W');

It gives me "06" (without quotes), but I only want 6, instead of 06. Is there a way to get the week of year in single character if the week is less than 10. I have couple of ways to deal with this, like:

  • Check if week is less than 10, then use substring.
  • etc..

Is there any more convenient way?

+4  A: 

Couldn't you just convert it into a int using intval().

Chacha102
A: 
settype($week = date('W'), 'int');
$week = (int) date('W');
$week = intval(date('W'));
//and my favorite
$week = date('W')+0;

i believe there is no other method left, correct me if you got another, i made this wiki.

useless