Page 1 of 1

Month String to Numeric?

Posted: Thu Oct 22, 2009 10:31 am
by spacebiscuit
Hi guys,

Given a month as a string, is there a simple way to find the numeric representation of said month?

I've used a switch statement but I'm wondring if there is a more elegant way of doing it?

Thanks in advance,

Rob.

Re: Month String to Numeric?

Posted: Thu Oct 22, 2009 10:39 am
by markusn00b
How about:

Code: Select all

 
echo date("m", strtotime'June'));
 

Re: Month String to Numeric?

Posted: Thu Oct 22, 2009 11:26 am
by spacebiscuit
Many thanks - that works perfectly and of course is far more elegant!

You were missing a opening bracket though :wink:

Rob.

Re: Month String to Numeric?

Posted: Thu Oct 22, 2009 12:20 pm
by markusn00b
robburne wrote:Many thanks - that works perfectly and of course is far more elegant!

You were missing a opening bracket though :wink:

Rob.
My bad.

You're welcome :)

Mark.